1
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
// Check if the key event was the BACK key and if there's history
if ((keyCode == KeyEvent.KEYCODE_BACK) && myWebView.canGoBack() {
myWebView.goBack();
return true;
}
// If it wasn't the BACK key or there's no web page history, bubble up to the default
// system behavior (probably exit the activity)
return super.onKeyDown(keyCode, event);
}
這段代碼取自http://developer.android.com/guide/webapps/webview.html。使用此代碼,進入網絡視圖後,我無法退出網絡視圖,除非我非常快地按兩次後退按鈕。有沒有辦法只按一次後退出網頁視圖?Android無法退出帶有後退按鈕的webview