我的视图寻呼机有 4 个片段。
mAdapter = new Adapter_viewPager(getActivity().getSupportFragmentManager());
mPager = (ViewPager) view.findViewById(R.id.pager);
mPager.setAdapter(mAdapter);
mPager.setOffscreenPageLimit(4);
这是适配器的代码:
public class Adapter_viewPager extends FragmentPagerAdapter
{
public Adapter_viewPager(android.support.v4.app.FragmentManager fm)
{
super(fm);
}
@Override
public int getCount() {
return 4;
}
@Override
public Fragment getItem(int position) {
switch (position) {
case 0:
return new me_fragment();
case 1:
return new myFriends_fragment();
case 2:
return new shareFB_fragment();
case 3:
return new sharePic_FB_layout();
default:
return null;
}
}
}
现在从片段 1 开始,我在单击某个按钮时调用新片段。这是代码:
android.support.v4.app.FragmentManager fm = getFragmentManager();
facebookPictureShareFragment objHomeFrag = new facebookPictureShareFragment();
android.support.v4.app.FragmentTransaction ft = fm.beginTransaction();
ft.replace(android.R.id.content, objHomeFrag);
ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
ft.addToBackStack(null);
ft.commit();
当我单击该按钮时,它会成功打开此片段,但是当我按下返回按钮时,它会给出异常Recursive entry to executePending Transctions
。
请帮我解决这个问题。