android - Blank page is shown when pop the fragment & replace to the same fragment again -


i have 3 fragments, frag_a, frag_b & frag_c.

my navigation logic is: frag_a ==> frag_b ==> frag_c . that's frag_a added layout firstly, so, @ first time, frag_a shown on screen, then, if user press next button, frag_a replaced frag_b, frag_b shown on screen, if user press next button, frag_b replaced frag_c, frag_c shown on screen.

everything works fine code @ point.

method change next fragment:

//here, argument 'fragment' either frag_b or frag_c public void showfragment(fragment fragment){    fragmentmanager fragmgr = activity.getsupportfragmentmanager();   fragmenttransaction fragtrans = fragmgr.begintransaction();    fragtrans.replace(r.id.frag_placeholder, fragment, fragmentname);   fragtrans.addtobackstack(null);    int transid = fragtrans.commit();   fragmgr.executependingtransactions();  } 

layout file of activity (frag_a added frag_placeholder when activity starts):

<?xml version="1.0" encoding="utf-8"?> <merge xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="fill_parent"     android:layout_height="fill_parent"     android:orientation="vertical"      >       <framelayout          android:id="@+id/frag_placeholder"         android:layout_width="fill_parent"         android:layout_height="fill_parent"       /> </merge> 

but, after frag_c shown, if pop frag_c press physical button , invoke showfragment(frag_c) method show frag_c again right after code detected physical button pressed, i blank page shown on screen. why & how fix it?

================explain=====================

i said above "*show frag_c again right after code detected physical button pressed*", here mean:

in activity:

@override public void onbackpressed() {   super.onbackpressed();   //i detect physical button pressed & invoke method show popped frag_c again. } 

based on @ luksprog 's comment, found if create new instance of frag_c instead of use same instance, blank page problem fixed.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -