【发布时间】:2013-08-05 12:41:24
【问题描述】:
如何将 Looper 与 asyncTask 一起使用?
调用 doImBackground 方法以编程方式创建名为 MyResultTable 的 TableLayout。反过来,MyResultTable 有一个处理程序,在MotionEvent.ACTION_MOVE 期间由 onTouch 调用。
在收到有关在 asynchTask 中使用句柄的投诉后,我决定在 UIThread 上运行处理程序。但这导致我的 onTouch 方法响应缓慢。所以我的问题是,如何将循环器与 asyncTask 一起使用?
UIThread 代码:
activity.runOnUiThread(new Runnable() {
public void run() {
handler.post(mResizeViews);
}
});
我的 Looper 尝试:(不工作:空白屏幕)
protected MyResultTable doInBackground(Void... params) {
Looper.prepare();
MyResultTable table = new MyResultTable(context, other);
Looper.loop();
return tabl;
}
【问题讨论】:
标签: android android-layout event-handling android-asynctask looper