我使用Handler从IntentService对象更新我的UI,但是,看起来runnable被执行,UI没有得到更新。这就是我的代码的样子:
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run () {
Log.d("DemoApp", getTitle());
title.setText(getTitle());
}
});
结果:它打印标题,但UI没有任何反应。这是什么?
答案 0 :(得分:0)
尝试在UI线程上运行
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run () {
Log.d("DemoApp", getTitle());
runOnUiThread(new Runnable() {
@Override
public void run() {
title.setText(getTitle());
}
});
}
});