How to set onBackPress in Fragment on Android -
in application use viewpager
show 2 fragments
activity.
in 1 of fragments
use navigationdrawer
, want when click on onbackpress
close navigationdrawer
.
i write below code open drawer :
reviewserialfrag_drawerlayout.opendrawer(gravity.end);
i want when click on onbackpress close drawer below code :
reviewserialfrag_drawerlayout.closedrawer(gravity.end);
how can it? please me
/try use below code snipet/ @override public void onbackpressed() { int count = getfragmentmanager().getbackstackentrycount(); // count --> current fragment if (count == 0) { if(reviewserialfrag_drawerlayout.isdrawervisible(gravitycompat.end)) { reviewserialfrag_drawerlayout.closedrawer(gravitycompat.end); } } }
Comments
Post a Comment