レイアウトに進行状況バーが必要です。合計時間は 30 秒で、毎秒刻みます。基本的に、アプリのユーザーに、時間切れになるまでに 30 秒あることを確認してもらいたいと考えています。
これは私が書いたコードです。しかし、これにより、アクティビティのない空の進行状況バーが表示されます。助けてください。私は何を間違っていますか
public class MySeekBarActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
setProgressBarVisibility(true);
final ProgressBar progressHorizontal = (ProgressBar) findViewById(R.id.progress_horizontal);
progressHorizontal.setProgress(progressHorizontal.getProgress()* 100);
new CountDownTimer(30000, 1000) {
public void onTick(long millisUntilFinished) {
progressHorizontal.incrementProgressBy(1);
int dtotal = (int) ( 30000 - millisUntilFinished ) /30000 * 100;
progressHorizontal.setProgress(dtotal);
}
public void onFinish() {
// DO something when 2 minutes is up
}
}.start();
}
}