Android Development (fragment) uses pop_back_stack_inclusive to jump to the bottom of the stack once. The use of similar ACTIVITY flag_activity_clear_top

Source: Internet
Author: User

Requirements Scenario:

The following scenario is encountered in development:

1. Create Fragment A display. The structure of this stack is:

  

1

2. Create Fragment B and display. From bottom to top, the structure of the stack is:

2.Fragment B
1.Fragment A

3. Create Fragment C and display. From bottom to top, the structure of the stack is:

3.Fragment C
2.Fragment B
1.Fragment A

So, how do I jump from Fragment C to Fragment A at once?

implementation:

When you enter the stack, use the method



Passed in a parameter name, which is a fregment, and is used below.

Code:

Fragmentmanager Fragmentmanager == fragmentmanager.begintransaction ();   =  Fragment.getclass (). GetName (); Fragmenttransaction.replace (R.id.container, Fragment). Addtobackstack (Nameforbackstackstate). commit ();

To do this when it pops up:

Fragmentmanager.popbackstackimmediate (FragmentA.class.getName (), Fragmentmanager.pop_back_stack_ INCLUSIVE);

The second parameter of this method

Pop_back_stack_inclusive

Indicates that this pop-up behavior is a one-time out-of-stack "specified name" for all Fragment above Fragment.


Reference:

Http://www.cnblogs.com/qixing/p/4015262.html

Android Development (fragment) uses pop_back_stack_inclusive to jump to the bottom of the stack once. ACTIVITY-like adoption of flag_activity_clear_top

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.