android - Manage Title with Fragment Stack Changed -
i using fragment activity , number of fragments added , poped out on press.
supposed adding fragment b fragment a. title of action bar set in changes navigating b; not restoring when pop fragment b out of fragment stack onresume of fragment not being called.
i using code:
fragmentmanager fragmentmanager = getsupportfragmentmanager(); fragmentmanager.begintransaction().add(r.id.container, fragmenttoreplace, tag).addtobackstack(tag).commit();
and pop out last fragment:
fragmentmanager.popbackstack();
how manage this. please suggest.
you can use onbackstackchanged
listener called whenever fragment popped back. add listener use this:
getfragmentmanager().addonbackstackchangedlistener(this);
in override function, check fragment popped , according can change actionbar title:
@override public void onbackstackchanged() { //check fragment framelayout container r.id.container // depending on fragment can change title settitle("xyz"); }
Comments
Post a Comment