Android WebView(使用是需要注意的坑)

1.HTML中使用了 select标签

android 中对应的WebView创建是需要依赖于Activity

即:

WebView webView=new WebView(Activity);正确

WebView webView=findViewById(R.id.xxx);正确

WebView webView=new WebView(getApplicationContext()); 错误

2.在重启该WebView页面不能点击

方法1:在onResume生命周期方法里添加 webView.resumeTimers()

方法2:设置 setDomStorageEnabled(true)

3.注意setWebChromeClient(前)和setWebViewClient(后)
4.webView.getUrl()可获取当前WebView访问的页面的URL


猜你喜欢

转载自blog.csdn.net/u012691505/article/details/80123379