Duplicate id, tag null, or parent id 0x0 with another fragment 解决方案
来源:互联网 发布:电脑做账软件 编辑:程序博客网 时间:2024/05/16 12:30
转:http://blog.csdn.net/hack8/article/details/25432503
在Fragment中如果内嵌了Fragment,那么在多次点击后内嵌的Fragment会遭成上述的问题Duplicate id tag null or parent id 0x0,因此我们需要在Fragment的OnDestroyView方法中销毁内嵌的Fragment,这样就可以解决上述的问题,具体代码如下:
- public class CopyOfSampleTitlesTriangle extends CopyOfBaseSampleFragment {
- private UserProfileFragment userProfileFragment;
- @Override
- public void onDestroyView()
- {
- // TODO Auto-generated method stub
- super.onDestroyView();
- //内嵌的Fragment UserProfileFragment
- UserProfileFragment userProfileFragment1 =(UserProfileFragment)getFragmentManager().findFragmentById(R.id.fr_user_profile_user_data_fragment);
- if(userProfileFragment1 !=null ){
- getFragmentManager().beginTransaction().remove(userProfileFragment1).commit();
- }
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState)
- {
- // TODO Auto-generated method stub
- //return super.onCreateView(inflater, container, savedInstanceState);
- View view = inflater.inflate(R.layout.fr_user_profile, null);
- mAdapter = new TestFragmentAdapter(getChildFragmentManager());
- mPager = (ViewPager)view.findViewById(R.id.pager);
- mPager.setAdapter(mAdapter);
- TitlePageIndicator indicator = (TitlePageIndicator)view.findViewById(R.id.viewpager_indicator);
- indicator.setViewPager(mPager);
- indicator.setFooterIndicatorStyle(IndicatorStyle.Triangle);
- mIndicator = indicator;
- final float density = getResources().getDisplayMetrics().density;
- //indicator.setBackgroundColor(0x18FF0000);
- indicator.setFooterColor(Color.WHITE);
- indicator.setFooterLineHeight(1 * density); //1dp
- indicator.setFooterIndicatorHeight(3 * density); //3dp
- //indicator.setFooterIndicatorStyle(IndicatorStyle.Underline);
- //indicator.setTextColor(0xAA000000);
- //indicator.setSelectedColor(0xFF000000);
- indicator.setSelectedBold(true);
- userProfileFragment =(UserProfileFragment)getFragmentManager().findFragmentById(R.id.fr_user_profile_user_data_fragment);
- //userProfileFragment =(UserProfileFragment)getChildFragmentManager().findFragmentById(R.id.fr_user_profile_user_data_fragment);
- User user=new User();
- user.fullName="test";
- user.description="test description";
- user.email="test@gmail.com";
- user.isFollowing=true;
- user.shortName="test";
- userProfileFragment.setUser(user);
- return view;
- }
- }
0 0
- Duplicate id, tag null, or parent id 0x0 with another fragment 解决方案
- Duplicate id, tag null, or parent id 0x0 with another fragment 解决方案
- Exception:Duplicate id 0x7f0b00d6, tag null, or parent id 0xffffffff with another fragment
- Fragment 内嵌Fragment问题——Duplicate id tag null or parent id 0x0 错误解决方案
- Duplicate id xxx, tag null, or parent id xxx with another fragment for xxxFragment
- Binary XML file line #13: Duplicate id 0x7f070055, tag null, or parent id 0x7f070054 with another fr
- Must specify unique android:id, android:tag, or have a parent with an id for XXX
- Resources$NotFoundException: String resource ID #0x0
- android.content.res.Resources$NotFoundException: String resource ID #0x0 找不到资源文件ID #0x0
- android.content.res.Resources$NotFoundException: String resource ID #0x0 找不到资源文件ID #0x0
- android.content.res.Resources$NotFoundException: String resource ID #0x0 找不到资源文件ID #0x0
- android.content.res.Resources$NotFoundException: String resource ID #0x0 找不到资源文件ID #0x0
- android.content.res.Resources$NotFoundException: String resource ID #0x0
- android.content.res.Resources$NotFoundException: String resource ID #0x0
- android.content.res.Resources$NotFoundException: String resource ID #0x0
- android.content.res.Resources$NotFoundException: String resource ID #0x0
- mob短信奔溃NotFoundException: String resource ID #0x0
- android.content.res.Resources$NotFoundException: String resource ID #0x0
- xml解析
- Webrtc Intro - kurento
- OC UIFont字体设置
- mongodb格式化结果
- java中的内部类总结
- Duplicate id, tag null, or parent id 0x0 with another fragment 解决方案
- 线程绑定CPU核-sched_setaffinity
- mac编译Android版本ffmpeg的x86_64架构库
- 懒加载、plist文件数据加载、图片显示
- 【LEETCODE】190-Reverse Bits
- 【归纳】读书与心智——心智工具箱
- ios NSCharacterSet使用讲解
- 移动端html5开发关于用js检测用户设备
- Android dialog 对话框自定义布局