看板 AndroidDev 關於我們 聯絡資訊
最近想寫個讓程式擷取網頁原始碼資料並SHOW在TEXTVIEW已確定動作有成功~ 參考網路上許多相關CODE發現有用HTTPURLCONNECT的..HTTPPOST的.. 後來覺得這個寫法似乎比較簡潔...可是不知道為何都沒有反應... 請問是哪裡有問題呢?? 感謝指教~~ TextView getwebdata = (TextView) findViewById (R.id.getdata); String savegetwebdata =getwebdata.getText().toString(); try { HttpClient hc = new DefaultHttpClient(); HttpGet get = new HttpGet("http://www.google.com"); HttpResponse echo = hc.execute(get); if (echo.getStatusLine().getStatusCode() == HttpStatus.SC_OK) { //getwebdata.setText(savegetwebdata+"HttpStatus SC_OK" ); InputStream is = echo.getEntity().getContent(); //savegetwebdata =getwebdata.getText().toString(); getwebdata.setText(savegetwebdata+is ); } } catch (Exception e) { // TODO: handle exception } -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 114.34.226.28
ericinttu:是什麼沒有反應? 09/01 10:37
Magicx:textview沒有顯示出網頁回傳資料 09/01 19:18
minksable:我的作法:http://pastebin.com/YGmtbiKc 09/02 13:51
minksable:直接丟InputStream要TextView顯示應該行不通吧? 09/02 13:53