android - Up navigation not appearing, when opening Fragments not in runtime -
the application consists of 1 activity
navigationdrawer
, can open fragment
s in 2 level hierarchy also. in latter case, have back button
on actionbar
implement navigation.
works fine @ runtime, if open fragments in 2 level hierarchy click events, when same code - same code -, navigation button won't show up. navigation still works. if navigate home level, navigationbar
's hamburger icon show up, , if open fragment
s in 2 level hierarchy click events, button show instead of hamburger icon should.
in short: works fine again, if navigate home level.
the related methods:
private void shoulddisplayhomeasup() { fragmentmanager fragmentmanager = getsupportfragmentmanager(); boolean shoulddisplay = fragmentmanager.getbackstackentrycount()>0; actionbar actionbar = getsupportactionbar(); if (actionbar != null) { actionbar.setdisplayhomeasupenabled(shoulddisplay); charsequence actionbartitle = actionbar.gettitle(); if (ismainlistfragment(shoulddisplay, actionbartitle)) { actionbar.settitle(r.string.app_name); setdrawerenabled(true); } } } private void setdrawerenabled(boolean enabled) { if (!enabled) { disabledrawer(); enableactionbarbacknavigation(); } else { enabledrawer(); } } private void disabledrawer() { drawerlayout.setdrawerlockmode(drawerlayout.lock_mode_locked_closed); actionbardrawertoggle.setdrawerindicatorenabled(false); actionbardrawertoggle.syncstate(); } private void enabledrawer() { drawerlayout.setdrawerlockmode(drawerlayout.lock_mode_unlocked); actionbardrawertoggle.setdrawerindicatorenabled(true); actionbardrawertoggle.syncstate(); } private void enableactionbarbacknavigation() { actionbardrawertoggle.settoolbarnavigationclicklistener(new view.onclicklistener() { @override public void onclick(view view) { onbackpressed(); } }); }
the shoulddisplayhomeasup()
method called onbackstackchanged()
, there no difference, when call in static manner.
call actionbar.setdisplayhomeasupenabled()
, actionbardrawertoggle.setdrawerindicatorenabled(false)
methods.
if set reminder in application, trigger notification. when click on notification, open main screen - home level -, list - can see above -, , detaild view of notification related todo. can navigate in view hierarchy. purpose open fragments programmatically.
Comments
Post a Comment