Duplicate id, tag null, or parent id 0x0 with another fragment 解决方案

前面一篇文章讲解了如何解决这个问题,但是同时引起了其他的问题,经过多方查找解决方案,发现使用如下的方法可以解决。

前面的文章为:http://blog.csdn.net/hack8/article/details/24680995

现在的解决方案

@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState)
	{
		// TODO Auto-generated method stub
		//return super.onCreateView(inflater, container, savedInstanceState);
		
		if( view!=null){ ViewGroup parent=(ViewGroup)view.getParent(); if( parent!=null) parent.removeView(view); }
		try{
			
		
		
			view = inflater.inflate(R.layout.fr_user_profile, null);
			mAdapter = new CopyOfTestFragmentAdapter(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;
	       	        
	        userProfileFragment =(UserProfileFragment)getFragmentManager().findFragmentById(R.id.fr_user_profile_user_data_fragment);
	        
	        User user=new User();
	        user.fullName="booksunking";
	        user.description="book description";
	        user.email="[email protected]";
	        user.isFollowing=true;
	        user.shortName="book";
	       
	        userProfileFragment.setUser(user);
		}
		catch(InflateException e){
			
		}
		return view;
	}


 

你可能感兴趣的:(Duplicate id, tag null, or parent id 0x0 with another fragment 解决方案)