android - how to use toolbar(humburger icon) as backstack navigation -
i have navigate fragment mainactivity , if have more 1 fragment in activity, need navigate 1 one using toolbar(humburger icon).
in fragment hosting toolbar, call activity backpress:
@override public boolean onoptionsitemselected(menuitem item) { switch (item.getitemid()) { case android.r.id.home: getactivity().onbackpressed(); break; } return true; }
to change icon arrow, in fragment:
actionbar actionbar = getactivity().getsupportactionbar(); if (actionbar != null) { // loading arrow drawable. final drawable uparrow = getresources().getdrawable(r.drawable.abc_ic_ab_back_mtrl_am_alpha); // should work actionbar.sethomeasupindicator(uparrow); actionbar.setdisplayhomeasupenabled(true); actionbar.sethomebuttonenabled(true); }
Comments
Post a Comment