Clear a Fragment in the Fragment rollback stack and clear the fragment rollback

Source: Internet
Author: User

Clear a Fragment in the Fragment rollback stack and clear the fragment rollback

Stack exit method:
GetActivity (). getsuppfrfragmentmanager (). popBackStackImmediate (CreateOneFragment. class. getName (), FragmentManager. POP_BACK_STACK_INCLUSIVE );

That is, the Fragment of all (including itself) above the Tag CreateOneFragment is displayed.

PopBackStackImmediate (name, flag );

The second parameter can only be 0 or 1 (pop_back_stack_random SIVE );

 

When the first parameter is null,

When the second parameter is 0:

The top fragment in the rollback stack is displayed.

As tested, the number of fragment in the rollback stack is reduced by one.

When the second parameter is 1:

The fragment of all rollback Stacks is displayed.

As tested, the number of fragment in the rollback Stack has changed to 0.

 

When the first parameter is not empty,

Based on the value of the second parameter, if it is flag = 0, all the above statuses will pop up;

If the flag is set to pop_back_stack_sive Sive, all the above statuses will pop up.

 

 

 

Ps: Method of stack entry

FragmentManager fragmentManager = getFragmentManager();FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();String name = fragment.getClass().getName();fragmentTransaction.replace(R.id.container, fragment).addToBackStack(nameForBackstackstate).commit();

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.