2013-10-12 72 views

回答

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; 
    } 

} 
+0

得到響應執行此 1)進行HTTP請求,但哪裏是計劃在那裏我可以插入的部分網址? –

+0

@AlessandroNardi我編輯我的代碼看看它。 –

+0

但是,如果我複製我的URL該程序不起作用。 –

0

有兩個步驟,以在的AsyncTask 2)將給你會從URL像這樣

while((text = stream.readLine()) != null) 
{ 
    result += text ; 
} 
textView.setText(Html.fromHtml(result)); 
+0

你可以做一個程序,希望我問,併發送給我的電子郵件或以其他方式?謝謝 –