Fragment 内嵌Fragment问题——Duplicate id tag null or parent id 0x0 错误解决方案
来源:互联网 发布:想做淘宝客服 编辑:程序博客网 时间:2024/04/30 01:26
在Fragment中如果内嵌了Fragment,那么在多次点击后内嵌的Fragment会遭成上述的问题Duplicate id tag null or parent id 0x0,因此我们需要在Fragment的OnDestroyView方法中销毁内嵌的Fragment,这样就可以解决上述的问题,具体代码如下:
public class CopyOfSampleTitlesTriangle extends CopyOfBaseSampleFragment { private UserProfileFragment userProfileFragment; @Overridepublic 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; } }
2 0
- Fragment 内嵌Fragment问题——Duplicate id tag null or parent id 0x0 错误解决方案
- 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
- 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
- ILJMALL project过程中遇到Fragment嵌套问题:IllegalArgumentException: Binary XML file line #23: Duplicate id
- Must specify unique android:id, android:tag, or have a parent with an id for XXX
- android.content.res.Resources$NotFoundException: Resource ID #0x0,错误
- fragment(8)根据id查找fragment
- no view for id xxx for fragment错误
- 错误:java.lang.illegalArgumentException:No view id found for fragment
- 339_No view found for id for fragment错误
- Fragment报java.lang.IllegalArgumentException:No view found for id 0x7f070250的错误
- 转:Fragment报java.lang.IllegalArgumentException:No view found for id 0x的错误
- fragment 重影问题,原来是布局id相同导致的
- Resources$NotFoundException: String resource ID #0x0
- fragment 里面 内嵌 fragment
- epoll通讯机制
- Hibernate映射List
- javaScript基础知识学习总结
- Google Protocol Buffers介绍和总结
- Hibernate映射Set
- Fragment 内嵌Fragment问题——Duplicate id tag null or parent id 0x0 错误解决方案
- Hibernate映射Map
- 数据库事务与隔离级别
- Hibernate乐观锁与悲观锁
- Hibernate缓存简介及领域对象的三种状态
- linux的epoll模型详解
- Hibernate查询结果排序
- Hibernate多对多双向关联
- Hibernate组件映射