我必须从此网址获取文字:http://diavolivicenza.blogspot.it/2013/10/il-ritorno-di-michele-valbusa-07102013.html并且我必须仅将文字和图片显示在布局中。例如,我想更改文本的颜色或大小。我只想要文字和图片。感谢
答案 0 :(得分:0)
试试这个,
while ((line = reader.readLine()) != null) {
result += line + "\n";
}
HTML = result;
试试这个:
outtext.setText(Html.fromHtml(HTML));
而不是在主线程中执行网络操作,我建议你使用AsyncTask在单独的线程中执行此操作
使用此,
private void getHTML() throws ClientProtocolException, IOException
{
HttpClient httpClient = new DefaultHttpClient();
HttpContext localContext = new BasicHttpContext();
HttpGet httpGet = new HttpGet("http://artistone.appone.nl/api/biografie.php?dataid=998"); //URL!
HttpResponse response = httpClient.execute(httpGet, localContext);
String result = "";
BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
String line = null;
while ((line = reader.readLine()) != null) {
result += line + "\n";
HTML = result;
}
}
答案 1 :(得分:0)
执行此操作有两个步骤 1)在AsyncTask中生成Http请求 2)解析你将从这个网址获得的响应
while((text = stream.readLine()) != null )
{
result += text ;
}
textView.setText(Html.fromHtml(result));