1
我打电话从工作线程创建一个辅助类功能,其中我想提出一个烤面包,但我我得到以下异常
Android Can't create handler inside thread that has not called Looper.prepare
我们不能从非UI线程提出一个敬酒吗?
我打电话从工作线程创建一个辅助类功能,其中我想提出一个烤面包,但我我得到以下异常
Android Can't create handler inside thread that has not called Looper.prepare
我们不能从非UI线程提出一个敬酒吗?
您可以使用runOnUiThread()
例如
this.runOnUiThread(show_toast);
和show_toast
private Runnable show_toast = new Runnable()
{
public void run()
{
Toast.makeText(Autoamtion.this, "My Toast message", Toast.LENGTH_SHORT)
.show();
}
};
不,你不能.. – Guna
为什么你没有张贴此问题之前,使用谷歌? –
你不能那样做。抱歉。 您必须调用UI线程才能显示Toast –