android - Fragments. ActionBar Back navigation -


i have 1 activity , 3 fragments. when go 1 fragment write transaction backstack:

transaction.addtobackstack(null); 

when press arrow on actionbar , go first fragment arrow lose , it's right.

 switch (item.getitemid()) {         case android.r.id.home:             fragmenttransaction fragmenttransaction = getfragmentmanager().begintransaction();             officialnamefragment offname = new officialnamefragment();             fragmenttransaction.remove(offname);             fragmenttransaction.commit();             getfragmentmanager().popbackstack(); 

((appcompatactivity)getactivity()).getsupportactionbar() .setdisplayhomeasupenabled(false);

            return true;          default:             return super.onoptionsitemselected(item);     } 

but if press system button , go first fragment arrow stay , it's wrong.

when override system button in activity that

@override public void onbackpressed(){     super.onbackpressed();     getsupportactionbar().setdisplayhomeasupenabled(false); } 

back arrow lose when go third second fragments. necessary arrow disappears when transition second first fragment.


Comments