我知道發生了誤差,因爲我嘗試把主線程上的網絡電話,所以我需要使用一個處理器或的AsyncTask通過處理器/的AsyncTask或類似的運行網絡任務
但是我不似乎能夠得到它的權利
這是代碼即時試圖去上班
try {
// Create a URL for the desired page
URL url = new URL("http://darkliteempire.gaming.multiplay.co.uk/testdownload.txt");
// Read all the text returned by the server
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
String str;
while ((str = in.readLine()) != null) {
// str is one line of text; readLine() strips the newline character(s)
eventText.setText(str);
eventText.setText(in.readLine());
}
in.close();
} catch (MalformedURLException e) {
Toast.makeText(getBaseContext(), "MalformedURLException", Toast.LENGTH_LONG).show();
} catch (IOException e) {
Toast.makeText(getBaseContext(), "IOException", Toast.LENGTH_LONG).show();
}
,我想叫它單擊此按鈕時
public void onClick(View v) {
if (v.getId() == R.id.update) {
}
}
是任何人能告訴我什麼是我應該換的第一位和如何調用它從的onClick