简体   繁体   English

android中进度对话时限

[英]Time limit for progress dialogue in android

How can I set time limit for ProgressDialog in android application.Can anybody help me for this如何在 android 应用程序中设置 ProgressDialog 的时间限制。有人可以帮我吗

pass the Dialog object and time to this method将 Dialog object 和时间传递给此方法

public void timerDelayRemoveDialog(long time, final Dialog d){
    Handler handler = new Handler(); 
    handler.postDelayed(new Runnable() {           
        public void run() {                
            d.dismiss();         
        }
    }, time); 
}

You can use android timer,below for the demo i have it wait for 5seconds.您可以使用 android 定时器,下面的演示我让它等待 5 秒。 Hope it answers.希望它回答。 Do let me know of any more query.请让我知道更多查询。

Timer timer;// Declare it above    
     timer = new Timer();//Initialized
                    timer.schedule(new TimerTask() {
                        @Override
                        public void run() {


    // cancel the progress dialogue after 5 seconds
                            progress.cancel(); 
                            timer.cancel();
                        }
                    }, 5000 ,5000);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM