java - Home button changing from drawer icon to up button on rotation - only when nav drawer is open -


i have implemented navigation drawer in app , part appears working ok.

i have home button set nav drawer icon(hamburger) , persists across normal rotations. can seen in image 1 (portrait) , image 2 (landscape after rotation). image 1

image 2

however if open nav drawer, rotate screen , close nav drawer, home button changes button, can seen in image 3. image 3

i have tried changes things around remains hamburger icon have had no luck.

my code mainactivity below.

public class mainactivity extends appcompatactivity { private string[] mnavigationdraweritemtitles; private drawerlayout mdrawerlayout; private listview mdrawerlist; toolbar toolbar; private string mdrawertitle; private string mtitle; actionbardrawertoggle mdrawertoggle; private static int snavposition = 0; private static final string nav_position_key = "navkey"; private static final string tag = mainactivity.class.getsimplename();  @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_main);     mdrawertitle = gettitle().tostring();     mtitle = gettitle().tostring();     mnavigationdraweritemtitles = getresources().getstringarray(r.array.drawer_fragment_items);     mdrawerlayout = (drawerlayout) findviewbyid(r.id.drawer_layout);     mdrawerlist = (listview) findviewbyid(r.id.left_drawer);     setuptoolbar();     navdraweritem[] navdraweritems = new navdraweritem[4];      navdraweritems[0] = new navdraweritem(getstring(r.string.nav_home));     navdraweritems[1] = new navdraweritem(getstring(r.string.nav_aims));     navdraweritems[2] = new navdraweritem(getstring(r.string.nav_arttrail));     navdraweritems[3] = new navdraweritem(getstring(r.string.nav_submission));      draweritemcustomadapter adapter = new draweritemcustomadapter(this, r.layout.drawer_list_item,navdraweritems);     view header = getlayoutinflater().inflate(r.layout.drawer_header,null);     mdrawerlist.addheaderview(header);     mdrawerlist.setadapter(adapter);     mdrawerlist.setonitemclicklistener(new draweritemclicklistener());     mdrawerlayout = (drawerlayout) findviewbyid(r.id.drawer_layout);     mdrawerlayout.adddrawerlistener(mdrawertoggle);     setupdrawertoggle();     if (savedinstancestate != null && savedinstancestate.containskey(nav_position_key)){         snavposition = savedinstancestate.getint(nav_position_key);     }     new draweritemclicklistener().selectitem(snavposition); }  private void setupdrawertoggle(){     mdrawertoggle = new actionbardrawertoggle(this,mdrawerlayout,toolbar,r.string.app_name,r.string.app_name);     getsupportactionbar().setdisplayhomeasupenabled(true);     mdrawertoggle.setdrawerindicatorenabled(true);     mdrawertoggle.syncstate(); }    @override protected void onpostcreate(@nullable bundle savedinstancestate) {     super.onpostcreate(savedinstancestate);     mdrawertoggle.syncstate(); }  private void setuptoolbar(){     toolbar = (toolbar) findviewbyid(r.id.toolbar);     setsupportactionbar(toolbar);  }    @override public void onsaveinstancestate(bundle outstate, persistablebundle outpersistentstate) {     super.onsaveinstancestate(outstate, outpersistentstate);     outstate.putint(nav_position_key,snavposition); } 

}

i have excluded unnecessary code regarding click listeners navigation.

any or suggestions appreciated. thank you.

try removing getsupportactionbar().setdisplayhomeasupenabled(true);and
mdrawertoggle.setdrawerindicatorenabled(true); ur
setupdrawertoggle();method

edit: setdisplayhomeasupenabled(false) hides default button 

Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -