Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/200.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 需要在HTML webview中显示文本格式的数据,如堆栈溢出_Android_Html_Android Layout_Android Webview - Fatal编程技术网

Android 需要在HTML webview中显示文本格式的数据,如堆栈溢出

Android 需要在HTML webview中显示文本格式的数据,如堆栈溢出,android,html,android-layout,android-webview,Android,Html,Android Layout,Android Webview,我有纯文本数据,它是按间隔行等格式设置的,但我想将此文本显示为HTML?如何做到这一点 [American Thinker] March 1, 2016 [American Thinker] [Navigation Menu] HomeArchivesVideoCartoonsAboutSearchLoginRules/FAQContactDonations Merchandise <http://www.americanmethod.com/american-thinker/&

我有纯文本数据,它是按间隔行等格式设置的,但我想将此文本显示为HTML?如何做到这一点

[American Thinker]

 March 1, 2016
 [American Thinker] [Navigation Menu]
 HomeArchivesVideoCartoonsAboutSearchLoginRules/FAQContactDonations
 Merchandise <http://www.americanmethod.com/american-thinker/>
 Home Archives Video Cartoons About Search Login More [Down Arrow]
   * Rules/FAQ
   * Contact
   * Donations
   * Merchandise <http://www.americanmethod.com/american-thinker/>


 American Thinker Blog

 Mexican oil giant devastated by oil price decline - 3/1/16 March 1, 2016 
 The state owned oil company that provides one third of the revenue of the 
 Mexican government is in a deep crisis, owing to low oil prices, 
<pre>
这是我的html:

       String htmlstuff = " \n" +
              "<html>\n" +
              "<header><title>This is title</title></header>\n" +
              "<body>\n" +


        "<pre style=\"white-space: pre-wrap;\">\n";

        htmlstuff=htmlstuff+result;
        htmlstuff=htmlstuff+
                " </pre>\n"+

              "</body>\n" +
              "</html>\n";
        wv.loadDataWithBaseURL("", htmlstuff, "text/html", "UTF-8", "");

        wv.setHorizontalScrollBarEnabled(false);
String htmlstuff=“\n”+
“\n”+
“这是标题\n”+
“\n”+
“\n”;
HTMLSUFF=HTMLSUFF+结果;
htmlstuff=htmlstuff+
“\n”+
“\n”+
“\n”;
wv.loadDataWithBaseURL(“,htmlstuff,“text/html”,“UTF-8”,”);
wv.setHorizontalScrollBarEnabled(假);
考虑一下这一点

你只需要把你的文字放在

属性显示它,但不显示水平滚动,如下所示


格式化文本
第2行有大空格

用于演示检查。

我会试试它包装不正确。我想一下。就一秒钟,这是一个很大的进步,现在结束。我更新了上面我现在得到的东西,请看我的帖子!我现在还看不到任何更新,你能在这里解释一下你的问题吗?我认为这也是正确的。我将用我的htmlanyway更新上面的内容,以消除换行符。包裹后它们似乎在错误的位置。。。
       String htmlstuff = " \n" +
              "<html>\n" +
              "<header><title>This is title</title></header>\n" +
              "<body>\n" +


        "<pre style=\"white-space: pre-wrap;\">\n";

        htmlstuff=htmlstuff+result;
        htmlstuff=htmlstuff+
                " </pre>\n"+

              "</body>\n" +
              "</html>\n";
        wv.loadDataWithBaseURL("", htmlstuff, "text/html", "UTF-8", "");

        wv.setHorizontalScrollBarEnabled(false);
<pre>
white-space: pre-wrap;
<pre style="white-space: pre-wrap;">
    Formated text
    Line 2      with wide spaces
</pre>