Android的,使用WebView loadData [英] Android, use WebView with loadData

查看:131
本文介绍了Android的,使用WebView loadData的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用的WebView是这样的:

 字符串的html =< HTML和GT;<身体GT;
    <表格样式\\背景色:#0a82a4;颜色:#FFFFFF; \\>
       ... 东东 ...
    < /表>
    < /身体GT;
    < /头>中;    html.replace(#,%23);
    html.replace(\\\\,%27);
    html.replace(%3f中,?);
    html.replace(%,%25);    myWebview.loadData(HTML,text / html的,UTF-8);

它的作品,但是当添加宽度=风格标签100%,web视图斜面加载数据。

我用这个参考:<一href=\"http://developer.android.com/reference/android/webkit/WebView.html#loadData%28java.lang.String,%20java.lang.String,%20java.lang.String%29\" rel=\"nofollow\">http://developer.android.com/reference/android/webkit/WebView.html#loadData(java.lang.String, java.lang.String中,java.lang.String中)

LOLL,解决:

  HTML = html.replace(%,25%);
的HTML = html.replace(#,%23);
的HTML = html.replace(\\\\,%27);
HTML = html.replace(%3F,?);


解决方案

要解决这个问题,我改变了顺序更换电话:

  HTML = html.replace(%,25%);
的HTML = html.replace(#,%23);
的HTML = html.replace(\\\\,%27);
HTML = html.replace(%3F,?);

im trying to use WebView like this:

    String html = " <html><body> 
    <table style\"background-color: #0a82a4; color: #ffffff;\"> 
       ... stuff ...
    </table>"
    </body>
    </head>";

    html.replace("#", "%23");
    html.replace("\\", "%27");
    html.replace("?", "%3f");
    html.replace("%", "%25");

    myWebview.loadData(html, "text/html", "utf-8");

It Works, but when add width=100% in style tag, webView cant load the data.

I used this reference: http://developer.android.com/reference/android/webkit/WebView.html#loadData(java.lang.String, java.lang.String, java.lang.String)

loll, solved:

html = html.replace("%", "%25");
html = html.replace("#", "%23");
html = html.replace("\\", "%27");
html = html.replace("?", "%3f");

解决方案

To solve this, I changed the order of replace calls:

html = html.replace("%", "%25");
html = html.replace("#", "%23");
html = html.replace("\\", "%27");
html = html.replace("?", "%3f");

这篇关于Android的,使用WebView loadData的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆