如何显示在一个正在运行的线程警告对话框? [英] How to show alert dialog in a running thread?

查看:204
本文介绍了如何显示在一个正在运行的线程警告对话框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

即时通讯开发一个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.

这篇关于如何显示在一个正在运行的线程警告对话框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆