Credit goes to StackOverFlow
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (event.getAction() == KeyEvent.ACTION_DOWN) {
switch (keyCode) {
case KeyEvent.KEYCODE_BACK:
if (mWebView.canGoBack()) {
mWebView.goBack();
} else {
finish();
}
return true;
}
}
return super.onKeyDown(keyCode, event);
}
=======================
For this code to work, you need to add a field to the Activity containing the WebView:private WebView mWebView;
Initialize it in the onCreate() method and you should be good to go.mWebView = (WebView) findViewById(R.id.webView);
-
were should I place that code? under all my code? or just under the loasUrl just like the builtinZoom? – zvzej May 20 '11 at 20:54
-
3You'd put it inside your activity, but outside the onCreate() method. – FoamyGuy May 20 '11 at 21:06