android - How to add GoBackSupport to three WebView Fragments? -
this situation: have three webview fragments
, if press backbutton
application closes. want these webview
fragments
goback
previous page. tried:
@override public boolean onkeydown(int keycode, keyevent event) { if ((keycode == keyevent.keycode_back) && webview.cangoback()) { webview.goback(); return true; } return super.onkeydown(keycode, event); }
but still does not work in fragments
. how make these webview
fragments
goback
?
addition: handle navigationdrawer
, there code in mainactivity.class
:
@override public void onbackpressed() { drawerlayout drawer = (drawerlayout) findviewbyid(r.id.drawer_layout); if (drawer.isdraweropen(gravitycompat.start)) { drawer.closedrawer(gravitycompat.start); } else { super.onbackpressed(); } }
@override public boolean onbackpressed() { webview.goback(); return true; }
try this