android - Understanding fragment stack -
i have action bar (actionbarsherlock) tab navigation , have couple of action items well. 1 of action items displays listfragment , here how call it:
case r.id.menuitem_info: // create new fragment , transaction sherlocklistfragment aboutlistfragment = new aboutlistfragment(); fragmenttransaction ft = getsupportfragmentmanager().begintransaction(); // replace whatever in fragment_container view fragment, // , add transaction stack ft.replace(r.id.root, aboutlistfragment); ft.addtobackstack(null); actionbar actionbar = getsupportactionbar(); actionbar.setdisplayhomeasupenabled(true); // commit transaction ft.commit(); return true; my problem when hit button, illegalargumentexception. i'm not sure how remove fragment view , display previous view?
here home button code:
case android.r.id.home: fragmentmanager fm = getsupportfragmentmanager(); if (fm.getbackstackentrycount() > 0) { fm.popbackstack(); } return true; any suggestions appreciated!
i did following in case android.r.id.home:
case android.r.id.home: fragmentmanager fm = getsupportfragmentmanager(); if(fm.getbackstackentrycount()>0){ onbackpressed(); } return true; i hope you, me works charm
Comments
Post a Comment