Android ListFragment in Tabs not showing on back button return -
i have (relatively) simple drill down application.
it has 1 activity (mainactivity) contains , transitions fragments.
public void gotopartnumbers(){ fragmenttransaction ft = getsupportfragmentmanager().begintransaction(); ft.setcustomanimations(r.anim.slide_in_right, r.anim.slide_out_left, r.anim.slide_in_right, r.anim.slide_out_left); ft.replace(r.id.container, new identifierfragment()).addtobackstack("partnumber").commit(); }
identifierfragment
tab layout la http://www.androidhive.info/2013/10/android-tab-layout-with-swipeable-views-1/
public class identifierfragment extends fragment implements actionbar.tablistener { private viewpager viewpager; private fragmentstatepageradapter madapter; private actionbar actionbar; private mainactivity mcontext; // tab titles private string[] tabs = { "part numbers", "oem numbers" }; public identifierfragment() { // required empty public constructor } @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { // inflate layout fragment view view = inflater.inflate(r.layout.partnumber_list, container, false); // initialization mcontext = (mainactivity) getactivity(); viewpager = (viewpager) view.findviewbyid(r.id.pager); actionbar = mcontext.getsupportactionbar(); actionbar.setnavigationmode(actionbar.navigation_mode_tabs); resetadapter( new identifierfragmentadapter(mcontext.getsupportfragmentmanager()) ); (string tab_name : tabs) { actionbar.addtab(actionbar.newtab().settext(tab_name) .settablistener(this)); } ...i can show rest don't think it's relevant return view; } @override public void ondetach(){ super.ondetach(); actionbar.setnavigationmode(actionbar.navigation_mode_standard); resetadapter(null); } public void resetadapter(fragmentstatepageradapter adapter){ actionbar.removealltabs(); viewpager.removeallviews(); madapter = adapter; viewpager.setadapter(madapter); } ... }
the 2 child fragments both listfragments cursorloaders. when row selected, identifierfragment
replaced using following method:
public void gotogallery(){ fragmenttransaction ft = getsupportfragmentmanager().begintransaction(); galleryhandle = new galleryfragment(); hashmap<string,string> selection = new hashmap<string, string>(); (hashmap<? extends string, ? extends string> c : mcriteria){ selection.putall(c); } galleryhandle.setselection(selection); ft.replace(r.id.container, galleryhandle).addtobackstack("gallery").commit(); }
when move identifierfragment
, works fine. can select row , go detail view. it's when attempt use button detail view viewpager
, no listviews
!
obviously can supply whatever other code needed. supplied thought relevant.
i'm @ loss, , help. in advance!
isn't because replace current fragment. perhaps if use .add() instead of .replace() when go new gallery
public void gotogallery(){ fragmenttransaction ft = getsupportfragmentmanager().begintransaction(); galleryhandle = new galleryfragment(); hashmap<string,string> selection = new hashmap<string, string>(); (hashmap<? extends string, ? extends string> c : mcriteria){ selection.putall(c); } galleryhandle.setselection(selection); ft.add(r.id.container, galleryhandle).addtobackstack("gallery").commit(); }
Comments
Post a Comment