如何在alertDialog打开时停止程序?
我想在alertDialog打开时停止主线程,并等待用户选择继续程序(取决于按下的按钮(正或负))。当尝试停止线程后。展示 ();对话框未绘制;如果挂起侦听器的 onDestract onClose 它可以工作,但代码很糟糕。
I want stop main thread, while alertDialog is open, and wait user's choice for continue the program (depending on the button pressed buttons (positive or negative)). When trying to stop thread after. show (); dialog is not draw; if hang listener's onDestract onClose it works, but the code is horrible.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你无法停止“主”线程,因为它是 gui 线程 - 你的alertDialog将变得无响应。您需要使用回调来执行所需的操作。
You can't stop "main" thread, since it's gui thread - your alertDialog will become irresponsive. You need to use callback to perform desired operations.
为什么需要停止主线程?这是什么游戏吗?
您必须使用多个线程,并且永远不要阻塞主线程。例如,逻辑线程,绘图线程。
如果您需要停止绘图,只需设置 noDraw=true 属性:)
像这样:
Why you need to stop main thread? Is this some game?
You must use many thread, and never block main thread. For example, thread for logic, thread for draw.
If you need to stop drawing, simple set your noDraw=true property:)
Like this: