2011-06-04 48 views
0

我希望設置進度條,直到下一個活動開始。這意味着我要在加載下一頁或活動時刪除黑屏。如何解決此問題?如何在android中設置進度條?

是的我使用按鈕onClick和使用listView來移動下一個活動。

+0

上? – Sumant 2011-06-04 08:56:17

回答

1
Button b1 = new Button(this); 
b1.setOnTouchListener(new OnTouchListener() 
      { 
       public boolean onTouch(View v, MotionEvent event) 
       { 
        int action = event.getAction(); 
        if(action==0) 
        { 
        } 
        else if(action == 1) 
        { 
         final ProgressDialog dialog = ProgressDialog.show(myFirstActivity.this,"Please wait","Loading...",true); 
         new Thread() 
         { 
           public void run() 
           { 
            try 
            { 
             Thread.sleep(2000); 
            } catch (InterruptedException e) 
            { 
             e.toString(); 
             e.printStackTrace(); 
            } 
            finally 
            { 
             dialog.dismiss();   
            } 
           } 
         }.start(); 
         } 
        return false; 
       } 
      }); 



    b1.setOnClickListener(new OnClickListener() 
       { 
        public void onClick(View v) 
        { 
          Intent i1 = new Intent(myFirstActiviyt.this,Second.class); 
          startActivity(i1); 
          } 
          }); 

試試這個

+0

謝謝Sumant – MMM 2011-06-06 09:17:54

+0

啊Sumant我需要一個更多的幫助,如何使用水平進度條,而不是這個 – MMM 2011-06-06 09:20:13

+0

只是去http://www.androidpeople.com/android-progress-dialog-style HTTP://eagle.phys。 utk.edu/guidry/android/progressBarExample.html http://developer.android.com/reference/android/widget/ProgressBar.html你會得到的信息@水平進度條 – Sumant 2011-06-06 09:26:33