Android DrawerLayout doesn't show the right indicator icon -
i'm trying use new drawerlayout list. problem though set drawer listener, indicator on actionbar still arrow icon instead of 3-line icon intends draw. following oncreate function:
public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_front_page); // swiping pager set msectionspageradapter = new sectionspageradapter(getsupportfragmentmanager()); mviewpager = (viewpager) findviewbyid(r.id.pager); mviewpager.setadapter(msectionspageradapter); // sliding drawer set mhabitcontract = new habitscontract(this); mdrawerlayout = (drawerlayout) findviewbyid(r.id.front_page_layout); mdrawerlist = (listview) findviewbyid(r.id.habit_list); mdrawerlayout.setdrawershadow(r.drawable.drawer_shadow, gravitycompat.start); mdrawerlist.setadapter(new habitadapter(mhabitcontract.gethabititems(), this)); // fixme: indicator image doesn't show mdrawertoggle = new actionbardrawertoggle( this, /* host activity */ mdrawerlayout, /* drawerlayout object */ r.drawable.ic_navigation_drawer, /* nav drawer image replace 'up' caret */ r.string.drawer_open, /* "open drawer" description accessibility */ r.string.drawer_close /* "close drawer" description accessibility */ ) { public void ondrawerclosed(view view) { //getactionbar().settitle(mtitle); invalidateoptionsmenu(); // creates call onprepareoptionsmenu() } public void ondraweropened(view drawerview) { //getactionbar().settitle(mdrawertitle); invalidateoptionsmenu(); // creates call onprepareoptionsmenu() } }; mdrawerlayout.setdrawerlistener(mdrawertoggle); // action bar set getactionbar().setdisplayhomeasupenabled(true); getactionbar().sethomebuttonenabled(true); getactionbar().setdisplayshowhomeenabled(true); }
can help?
update: found problem. added onpostcreate function follows, , it's working.
protected void onpostcreate(bundle savedinstancestate) { super.onpostcreate(savedinstancestate); // sync toggle state after onrestoreinstancestate has occurred. mdrawertoggle.syncstate(); }
you need syncstate()
call of actionbardrawertoggle
object onpostcreate()
@override protected void onpostcreate(bundle savedinstancestate) { super.onpostcreate(savedinstancestate); // sync toggle state after onrestoreinstancestate has occurred. mdrawertoggle.syncstate(); }
Comments
Post a Comment