如何显示在一个正在运行的线程警告对话框?线程、对话框、正在运行

2023-09-05 08:54:35 作者:戒掉你的暧昧

即时通讯开发一个Android Game.In这个游戏有轨道上列车的运行。这是正在运行的线程。我想告诉alertdialog时有发生碰撞。当应用alertdialog示值误差不能创建处理程序内螺纹已经不叫尺蠖。prepare IM()。

Im developing an android Game.In this game There are tracks on which trains runs. This is running thread. I want to show alertdialog when there is collision between . when im applying alertdialog showing error can't create handler inside thread that has not called looper.prepare().

推荐答案

您必须要创建 AlertDialog UI线程里面否则它永远不会工作。如果你在不同的线程中使用的MessageHandler ,也可以使用 runOnUiThread (使用可运行)来创建对话框中。

You must need to create AlertDialog inside UI thread else it will never work. If you are in different thread use MessageHandler or can use runOnUiThread(using runnable) to create your dialog inside.