2012-04-26 47 views
0

我想要設置它以便進度條加載15秒,然後繼續下一個活動。如何在android上設置延遲進度條

眼下的活動有:

public class MainActivity extends Activity { 

    /** Called when the activity is first created. */ 
    @Override 
    public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.main); 
    Button btn5 =(Button)findViewById(R.id.button); 

    btn5.setOnClickListener(new Button.OnClickListener() { 

     public void onClick(View v) { 
     Intent myIntent = new Intent(); 

     myIntent.setAction(Intent.ACTION_VIEW); 

     myIntent.setData(android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI); 
     setContentView(R.layout.loading); 

     }   
    }); 
    } 

} 

和XML頁面有:

<ProgressBar 
    android:id="@+id/progressBar1" 
    style="?android:attr/progressBarStyleHorizontal" 
    android:layout_width="match_parent" 
    android:layout_height="144dp" 
    android:layout_gravity="center_vertical" /> 

我想知道如何做出讓progressBar1負荷15秒,然後去結果。 xml

+0

代碼已經完成了所有的「閃屏」 Q&A的StackOverflow上看看,因爲這是在行爲上是相同的。最快的選項可能是在'Handler'上發佈'Runnable',延遲15秒,然後開始你的第三個'Activity'。 – 2012-04-27 01:56:37

+0

你可以做一個單獨的線程來處理進度條,給線程所需的延遲,然後解除進度條... – Sandeep 2012-04-27 04:49:04

回答

0

查看包含在sdk示例代碼中的api演示中的進度對話框示例。我相信它在/src/com/example/android/apis/app/AlertDialogSamples.java中。如果你看到最底層的代碼,它會通過時間延遲的消息更新進度條。

你的問題是有點不清楚,雖然,是您發佈的第一個或第二個活動

+0

我點擊一個按鈕來啓動這個活動,它等待,然後打開第三個活動,目標。 – CreeperHunter 2012-04-27 00:31:13