Cannot read property 'getItem' of null"
Uncaught TypeError: Cannot read property 'getItem' of null
WebSettings settings = mWebView.getSettings();
settings.setDomStorageEnabled(true);//开启DOM
settings.setDisplayZoomControls(false); //隐藏webview缩放按钮
//设置加载进来的页面自适应手机屏幕
settings.setUseWideViewPort(true);
settings.setLoadWithOverviewMode(true);
第一个方法设置webview推荐使用的窗口,设置为true。第二个方法是设置webview加载的页面的模式,也设置为true。
加载富文本
webView.loadDataWithBaseURL(null, mKnowledge.getArticle(), "text/html", "UTF-8", null);
WebSettings webSettings = webView.getSettings();
webSettings.setTextZoom(100);
webSettings.setJavaScriptEnabled(true);//允许使用js
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
webSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
}