如何在 onCreate 方法中显示对话框? [英] How to show Dialog in onCreate method?

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

问题描述

如何在 onCreate 方法中显示 Dialog ?这可能吗,我试过了,但我得到了泄漏的窗口异常.任何人都可以给我建议吗?

How to show Dialog in onCreate method ? Is that possible at all, I tried but I got leaked window exception. Can anyone suggest me anything ?

推荐答案

您可以在 Handler Class 的帮助下使用 ProgressDialog Class.这样您就可以实现您想做的事情.

you can use ProgressDialog Class with the Help of Handler Class. This way you can achieve what you want to do.

progDailog = ProgressDialog.show(loginAct,"Process ", "please wait....",true,true);

new Thread ( new Runnable()
{
     public void run()
     {
      // your loading code goes here
     }
}).start();


     Handler progressHandler = new Handler() 
     {

         public void handleMessage(Message msg1) 
         {

             progDailog.dismiss();
             }
     }

这篇关于如何在 onCreate 方法中显示对话框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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