descriptionView.loadData(data.description, "text/html", "utf-8");在有些手机上会出现乱码,将方法变成descriptionView.loadDataWithBaseURL(null,data.description, "text/html", "utf-8",null);就可以解决这个问题。
例子:
//详细内容,显示的是html的内容;
WebView descriptionView=(WebView) this.findViewById(R.id.description);WebSettings ws = descriptionView.getSettings();
ws.setJavaScriptEnabled(false);
ws.setAllowFileAccess(true);
ws.setBuiltInZoomControls(false);
ws.setSupportZoom(false);
/**
* 设置网页布局类型:
* 1、LayoutAlgorithm.NARROW_COLUMNS : 适应内容大小
* 2、LayoutAlgorithm.SINGLE_COLUMN: 适应屏幕,内容将自动缩放
*
*/
ws.setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);
ws.setDefaultTextEncodingName("utf-8"); //设置文本编码
ws.setAppCacheEnabled(true);
ws.setCacheMode(WebSettings.LOAD_DEFAULT);//设置缓存模式</span>
descriptionView.loadDataWithBaseURL(null,data.description, "text/html", "utf-8",null);