2

これは私が PorgressDialog を作成する方法です:

... progressBarDialog = new ProgressDialog( context );
                  progressBarDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
progressBarDialog.show(this, "Please Wait", "Updating your GPS coordinates",false,true);


//Trigger GPS service to update coordinates
fg.myOnresume(Name);
fg.dontSendSMS();
//Sets the timer at 30 secs
timer= new Timer();
timer.schedule(new startMapActivity());
}
class startMapActivity extends TimerTask 
    {
        @Override
        public void run() 
        {
            //handler.sendEmptyMessage(0);
            Log.d("", "StartMapActivty--->>>run()");
            // Dismissing Dialog Box
            if(progressBarDialog.isShowing())
            {
                progressBarDialog.dismiss();
            }

        }
    }

基本的に、タイマーが30秒後に終了した後、ダイアログを閉じたいのですが、機能していません:(助けてください。

4

3 に答える 3

3

非 UI スレッドから UI を変更することはできません。ハンドラーを使用してそれを行います。

于 2011-03-25T12:01:17.430 に答える
1

コードを少し変更します。お気に入り:

    Runnable r = new Runnable()
    {

        public void run() 
        {
           // TODO Auto-generated method stub
           //dismiss your dialoge here....
        }
    };

これを次のように呼び出すことができます:

  Handler h = new Handler();
  h.postDelayed(r, delayMillis);
于 2011-03-25T12:32:40.347 に答える
0

このスレッドを確認してください: Android での ProgressDialog の却下

于 2011-03-25T12:04:59.553 に答える