我正在尝试将VIEwPager添加到DialogFragment:
public class FirstlaunchdialogFragment extends DialogFragment {@OverrIDepublic voID onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setStyle(DialogFragment.STYLE_norMAL,R.style.theme_Sherlock_light_Dialog);}@OverrIDepublic Dialog onCreateDialog(Bundle savedInstanceState) { final VIEw v = getActivity().getLayoutInflater().inflate( R.layout.fragment_dialog_first_launch,null); VIEwPager vIEwPager = (VIEwPager) v.findVIEwByID(R.ID.pager); vIEwPager.setAdapter(new FirstLaunchFragmentsAdapter(getChildFragmentManager())); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setVIEw(v).setInverseBackgroundForced(true); return builder.create();}}
由于某些原因,它会崩溃说:
04-06 00:00:49.600: E/AndroIDRuntime(3734): java.lang.IllegalStateException: Fragment does not have a vIEw04-06 00:00:49.600: E/AndroIDRuntime(3734): at androID.support.v4.app.Fragment.findVIEwByID(Fragment.java:1425)04-06 00:00:49.600: E/AndroIDRuntime(3734): at androID.support.v4.app.FragmentManagerImpl.movetoState(FragmentManager.java:901)04-06 00:00:49.600: E/AndroIDRuntime(3734): at androID.support.v4.app.FragmentManagerImpl.movetoState(FragmentManager.java:1088)04-06 00:00:49.600: E/AndroIDRuntime(3734): at androID.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)04-06 00:00:49.600: E/AndroIDRuntime(3734): at androID.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1444)04-06 00:00:49.600: E/AndroIDRuntime(3734): at androID.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:461).....
我一直在谷歌搜索片段没有视图异常半天现在没有结果
在我看来,适配器不能膨胀布局或东西……
这是我的片段和适配器
public static class UserWelcomeFragment extends Fragment { public static UserWelcomeFragment newInstance() { return new UserWelcomeFragment(); } @OverrIDe public VIEw onCreateVIEw(LayoutInflater inflater,VIEwGroup container,Bundle savedInstanceState) { VIEw v = inflater.inflate(R.layout.fragment_welcome_user,container,false); return v; }}private class FirstLaunchFragmentsAdapter extends FragmentPagerAdapter { public FirstLaunchFragmentsAdapter(FragmentManager fm) { super(fm); } @OverrIDe public Fragment getItem(int arg0) { switch (arg0) { case 0: return UserWelcomeFragment.newInstance(); case 1: return new IntegrationSelectingDialogFragment(); default: return UserWelcomeFragment.newInstance(); } } @OverrIDe public int getCount() { return 2; }}
编辑:https://code.google.com/p/android/issues/detail?id=42601看起来相关
编辑2:我正在测试API 16,该项目正在使用支持库v4修订版12
解决方法 您正在测试哪个AndroID版本? VIEwPagers使用片段,并且因为您的VIEwPager本身就是片段,所以您正在嵌套片段.嵌套片段仅支持API 17(Jellybean),因此此实现仅适用于安装了AndroID 4.1的设备. 总结以上是内存溢出为你收集整理的android – DialogFragment中的ViewPager,IllegalStateException:Fragment没有视图全部内容,希望文章能够帮你解决android – DialogFragment中的ViewPager,IllegalStateException:Fragment没有视图所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)