I have a Fragment
which contains a ViewPager
which contains two Fragment
s. In one of the ViewPager
's Fragments
I have a list of items. When I click on the item, I want the whole Fragment
containing the ViewPager
to be replaced with a new Fragment
which represents details about the item that was clicked (similar to starting a new Activity
which replaces the existing one). I do like this:
CustomFragment fragment = new CustomFragment();
FragmentTransaction transaction = getActivity().getSupportFragmentManager().beginTransaction();
transaction.replace(R.id.container, fragment);
transaction.addToBackStack(null);
transaction.commit();
but it only replaces the Fragment
of the ViewPager
where the list of items is, not the whole Fragment
that represents the ViewPager
. How to achieve that the whole ViewPager
Fragment
would be replaced, not its child Fragment
?
您需要获得对包含选项卡的整个容器的FragmentActivity
的引用。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.