android - WebView backbutton -
my webview loading previous page when backbutton being pressed, without me overriding onbackpressed() method. wondering how prevent behavior, since not desired design of app. backbutton should merely does, navigate fragments/activities, not webview itself.
webview = (webview) getview().findviewbyid(r.id.webview); webview.setwebviewclient(new internalwebclient()); webview.getsettings().setjavascriptenabled(true); webview.getsettings().setlayoutalgorithm(layoutalgorithm.narrow_columns); webview.getsettings().setloadsimagesautomatically(true); webview.setscrollbarstyle(view.scrollbars_inside_inset); webview.setlayertype(view.layer_type_software, null);
regards.
ok, simple enough...
webview.setonkeylistener(new view.onkeylistener() { @override public boolean onkey(view v, int keycode, keyevent event) { if (keycode == keyevent.keycode_back) { myactivity.this.finish(); // or getactivity().finish() when in fragment } return false; } });
Comments
Post a Comment