【发布时间】:2013-07-26 06:31:40
【问题描述】:
我想在 AsyncTask 类中使用 findViewById() 方法...我尝试了 onPostExecute() 和 onPreExecute()。但它不起作用
class Proccess extends AsyncTask<String, Void, Void>{
@Override
protected Void doInBackground(String... arg0) {
TextView txt = (TextView) findViewById(R.id.tvResult); // cause error
return null;
}
@Override
protected void onPreExecute() {
super.onPreExecute();
TextView txt = (TextView) findViewById(R.id.tvResult); // cause error
}
@Override
protected void onPostExecute(Void result) {
super.onPostExecute(result);
TextView txt = (TextView) findViewById(R.id.tvResult); // cause error
}
}
【问题讨论】:
-
为什么要在异步任务中使用 TextView?
-
用于更改文本 + 我想向 RelativeLayout 添加更多文本视图!
标签: java android asynchronous