【发布时间】:2011-02-26 20:07:59
【问题描述】:
我有以下基于异步任务的代码块。 我正在尝试通过 return LoadFeed() 返回一个 List 变量 doInBackground 的返回类型是 String。 如果我将 doInBackground 的返回类型从 String 更改为 List 然后我得到一个错误
"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);
}
}
【问题讨论】:
标签: android list android-asynctask