android - How to remove hidden fragments -
i'm trying switch layout total view double pane view following:
....... ....... . . . . . . --> ....... . . . . ....... .......
now issue i'm going 1 container fragment 2 containers fragment in each. in order i'm removing old fragment , adding new ones. when remove fragment in big 1 old fragment appears instead. i've set tag on old fragment , search after getfragmentmanager().findfragmentbytag()
returns null.
for hack utilize largeview.setvisibility(view.gone); there improve way handle this?
edit:
it seems bug isn't reproduced longer. means replace should have done along. why did glitch? eclipse? android?
edit2
this how replace fragments:
fragment fragment = new simplescannerfragment();
fragmenttransaction ft = getfragmentmanager().begintransaction(); ft.replace(r.id.main_container, fragment, scan_fragment_tag); ft.commit();
before switching double pane layout pop stack this:
getfragmentmanager().popbackstack(null, fragmentmanager.pop_back_stack_inclusive);
i remove fragments using this:
removefragment = getfragmentmanager().findfragmentbytag(scan_fragment_tag); if(removefragment != null) { getfragmentmanager().begintransaction().remove(removefragment).commit(); }
i'm switching views visiblity when go single double pane:
// hide main layout well, hacks in case again... framelayout frame = (framelayout) this.findviewbyid(r.id.main_container); frame.setvisibility(view.gone); // add together new layout fragmenttransaction ft = getfragmentmanager().begintransaction(); custommapfragment fragment = custommapfragment.newinstance(); scorefragment scorefragment = new scorefragment(); ft.replace(r.id.main_narrow_bot_container, fragment); ft.replace(r.id.main_narrow_top_container, scorefragment); ft.commit();
how trying clear entire stack?
private void clearbackstack(){ fragmentmanager fragmentmanager = getfragmentmanager(); fragmentmanager.popbackstack(null, fragmentmanager.pop_back_stack_inclusive); fragmentmanager.popbackstackimmediate(); }
android fragment
No comments:
Post a Comment