android webview加载String类型html

    xiaoxiao2021-03-25  141

     

    今天遇到解析json的时候html是String类型的,如下是解决方法:

     

     

    webView = (WebView) findViewById(R.id.bbs_webview); webView.getSettings().setJavaScriptEnabled(true); special_content = special_content.replaceAll("&", ""); special_content = special_content.replaceAll(""", "\""); special_content = special_content.replaceAll("<", "<"); special_content = special_content.replaceAll(">", ">"); special_content = special_content.replaceAll("\\n", "<br>");//换行 special_content = special_content.replaceAll("<img", "<img width=\"100%\"");//图片不超出屏幕 webView.loadDataWithBaseURL(null, special_content, "text/html", "utf-8", null);webView = (WebView) findViewById(R.id.bbs_webview); webView.getSettings().setJavaScriptEnabled(true); special_content = special_content.replaceAll("&", ""); special_content = special_content.replaceAll(""", "\""); special_content = special_content.replaceAll("<", "<"); special_content = special_content.replaceAll(">", ">"); special_content = special_content.replaceAll("\\n", "<br>");//换行 special_content = special_content.replaceAll("<img", "<img width=\"100%\"");//图片不超出屏幕 webView.loadDataWithBaseURL(null, special_content, "text/html", "utf-8", null);

     

     

     

     

     

    转载请注明原文地址: https://ju.6miu.com/read-10914.html

    最新回复(0)