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 –