如何把一个应用程序的主线程睡觉? [英] How to put an app main thread to sleep?

查看:97
本文介绍了如何把一个应用程序的主线程睡觉?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个当前的问题:我有一个应用程序,并希望把主线程睡眠1500毫秒显示我可以显示ProgressDialog,我不知道该怎么做。这是可能的停止应用程序的主线程?我可以用另一个线程权达到同样的目标?

I've a current problem : I've a app and want to put the main thread to sleep for 1500ms show a I can show a ProgressDialog, and I don't know how to do it. It's possible to stop an app main thread? I can achieve the same goal using another thread right?

推荐答案

停止主线程通常是一个坏主意,因为它也将停止所有的用户界面交互处理。

Stopping the main thread is usually a bad idea as it would also stop all UI interaction processing.

尝试使进度对话框模式。这将prevent从直到对话框消失在你的UI做任何用户。我认为这将实现你想要做什么,与Android是如何工作的兼容

Try making the progress dialog modal. This will prevent the user from doing anything on your UI until the dialog is gone. I think this will achieve what you want to do and is compatible with how Android works

这篇关于如何把一个应用程序的主线程睡觉?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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