更新时间:2022-12-19 16:08:44
如果您想在 WebView
可见时禁用后退按钮动作并在 WebView
可见时启用后退按钮动作> 在不可见 在您的活动中尝试以下代码
If you want to disable back button action when the WebView
Visible and enable back button action if the WebView
in not Visible try the below code in your Activity
@Override
public void onBackPressed() {
if(webview.getVisibility()==View.VISIBLE){
// dont pass back button action
if(webview.canGoBack()){
webview.goBack();
}
return;
}else{
// pass back button action
super.onBackPressed();
}
}