【问题标题】:Time limit for progress dialogue in androidandroid中进度对话的时间限制
【发布时间】:2011-07-12 09:24:28
【问题描述】:

如何在 android 应用程序中设置 ProgressDialog 的时间限制。谁能帮我解决这个问题

【问题讨论】:

    标签: java android eclipse progressdialog


    【解决方案1】:

    将Dialog对象和时间传递给这个方法

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

    【讨论】:

    • @ dennis 这是我的代码:- "public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setTheme(android.R.style.Theme_Holo); setContentView(R.layout.main ); ProgressDialog p= new ProgressDialog(this); p.setCancelable(true); p.setMessage("Loading..."); p.show(); getFeed(RSSFEEDOFCHOICE);} "我如何使用答案我的代码。我想要它 10 秒。请帮助
    • @bejoy 调用这个方法,比如 timerDelayRemoveDialog(10000,p);
    【解决方案2】:

    您可以使用 android timer ,下面的演示我让它等待 5 秒。 希望它回答。请让我知道更多查询。

    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);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-03-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多