中易网

android 的webview怎么展示后台传来没标签的html字符串

答案:1  悬赏:50  
解决时间 2021-01-12 04:26
  • 提问者网友:雨不眠的下
  • 2021-01-11 04:06
android 的webview怎么展示后台传来没标签的html字符串
最佳答案
  • 二级知识专家网友:十鸦
  • 2021-01-11 04:38
public class MainActivity extends Activity {
 
    @Override
 
    protected void onCreate(Bundle savedInstanceState) {
 
        super.onCreate(savedInstanceState);
 
        setContentView(R.layout.activity_main);        
 
        WebView wv = (WebView) findViewById(R.id.wvHtml);   
 
 
 
        wv.getSettings().setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);    
          
 
        htmlData = htmlData.replaceAll("&", "");
 
        htmlData = htmlData.replaceAll("quot;", """);
 
        htmlData = htmlData.replaceAll("lt;", "<");
 
        htmlData = htmlData.replaceAll("gt;", ">");
 
         
 
        wv.loadDataWithBaseURL(null, htmlData, "text/html", "utf-8", null);    
 
    }
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息!
大家都在看
推荐信息