移动开发 \ Android \ Android WebView(使用是需要注意的坑)

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

总点击284
简介:版权声明:本文为博主原创文章,未经博主允许不得转载。https://blog.csdn.net/u012691505/article/details/80123379

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u012691505/article/details/80123379

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


意见反馈 常见问题 官方微信 返回顶部