0

我正在开发一个新闻应用程序。Webservice 向我返回一个 HTML 代码字符串。这是一篇文章的内容:

String result;
// result is returned from Webservice
result = "<p>Simply put, the 2013 Billboard Music Awards included a sizable helping of Bieber, with two performances in three hours and a Top Male Artist win before the Milestone Award was presented. Three months after another Justin -- Mr. Timberlake -- kept popping up at the 2013 Grammys and threatened overexposure, perhaps the audience at the Billboard Music Awards simply tired of seeing Bieber show up on stage and snag more of the spotlight.<br/><img align=\"Middle\" alt=\"\" border=\"0\" class=\"oImage\" height=\"335\" src=\"http://img2.news.zing.vn/2013/05/22/u2.jpg\" width=\"500\" \\/><br/>Plus, in the middle of the perceived mayhem was a monster-selling tour, with tons of Beliebers blissfully taking in the spectacle. But a dark cloud seemed embedded within the scraps of news coming from Bieber's tour over the past few months, and the Billboard Music Award boos could have been festering ill will toward one, some or all of them.<br/><img align=\"Middle\" alt=\"\" border=\"0\" class=\"oImage\" height=\"289\" src=\"http://img2.news.zing.vn/2013/05/22/u1.jpg\" width=\"500\"/></p>";

如您所见,“结果”中有 2 个图片网址。“结果”是整篇文章的内容。

当我使用 TextView 查看本文的内容时,图像不显示:

TextView content = (TextView) findViewById(R.id.tvContent);
content.setText(Html.fromHtml(result));

我怎样才能显示这篇文章的内容适合屏幕并显示所有图像。这是我的代码

感谢您的帮助。

4

1 回答 1

0

你需要一个 Webview 这个。不是 textview。以下是它的实现方式。

    Description = (WebView)findViewById(R.id.webView1);
        Description.getSettings().setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);
        WebSettings webSettings = Description.getSettings();
        webSettings.setTextSize(WebSettings.TextSize.NORMAL);
Description.loadDataWithBaseURL (null, "<html><p>Simply put, the 2013 Billboard Music Awards included a sizable helping of Bieber, with two performances in three hours and a Top Male Artist win before the Milestone Award was presented. Three months after another Justin -- Mr. Timberlake -- kept popping up at the 2013 Grammys and threatened overexposure, perhaps the audience at the Billboard Music Awards simply tired of seeing Bieber show up on stage and snag more of the spotlight.<br/><img align=\"Middle\" alt=\"\" border=\"0\" class=\"oImage\" height=\"335\" src=\"http://img2.news.zing.vn/2013/05/22/u2.jpg\" width=\"500\" \\/><br/>Plus, in the middle of the perceived mayhem was a monster-selling tour, with tons of Beliebers blissfully taking in the spectacle. But a dark cloud seemed embedded within the scraps of news coming from Bieber's tour over the past few months, and the Billboard Music Award boos could have been festering ill will toward one, some or all of them.<br/><img align=\"Middle\" alt=\"\" border=\"0\" class=\"oImage\" height=\"289\" src=\"http://img2.news.zing.vn/2013/05/22/u1.jpg\" width=\"500\"/></p></html>", "text/html", "UTF-8",null);

而你的布局,

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >
            <WebView
                android:id="@+id/webView1"
                android:layout_width="match_parent"
                android:layout_height="match_parent" />

   </RelativeLayout>
于 2013-05-23T11:33:56.067 回答