How to disable back button pressed for webview in android?

前端 未结 6 779
时光说笑
时光说笑 2020-12-19 15:38

How to disable back button pressed for webview in android ?

@Override
public boolean onKeyDown(int keyCode, KeyEvent event)
{
     if (wv1 != null &&         


        
6条回答
  •  Happy的楠姐
    2020-12-19 16:17

    Please try this

       @Override
    public void onBackPressed() {
          if(webview.canGoBack()){
             webview.goBack();
          }
        else{
          super.onBackPressed();
       }
    }
    

提交回复
热议问题