如何在线程中显示Toast消息?

Mon*_*ali 0 android toast runtimeexception

我想Toast在线程中显示消息..但我得到了

RunTimeException:Can't create handler inside thread that has not called Looper.prepare()
Run Code Online (Sandbox Code Playgroud)

请帮我.提前致谢.

ing*_*abh 11

在线程中尝试以下代码

runOnUiThread(new Runnable() 
        {                
            @Override
            public void run() 
            {
                //Your toast code here
            }
        });
Run Code Online (Sandbox Code Playgroud)

Thread是非GUI线程会发生什么,您无法从非GUI线程访问GUI元素