我有以下基於asynctask的代碼塊。 我試圖通過返回LoadFeed() 返回一個List變量,doInBackground的返回類型是String。 如果我改變從字符串doInBackground的返回類型列出 然後我得到一個錯誤Android:無法指定列表<String> AsyncTask的返回類型:doInBackground
"The return type is incompatible with AsyncTask<String,Void,String>.doInBackground(String[])"
如何解決這個問題? 請幫助
感謝,
private class DispData extends AsyncTask<String, Void, String> {
private final ProgressDialog dialog = new ProgressDialog(MessageList.this);
// can use UI thread here
protected void onPreExecute() {
dialog.setMessage("Fetching scores...");
dialog.show();
}
// automatically done on worker thread (separate from UI thread)
protected String doInBackground(final String... args) {
return loadFeed();
}
// can use UI thread here
protected void onPostExecute(final List<String> result) {
if (dialog.isShowing()) {
dialog.dismiss();
}
adapter =
new ArrayAdapter<String>(MessageList.this,R.layout.row,result);
MessageList.this.setListAdapter(adapter);
}
}
感謝您的提示! – sammydude