在我的android項目中,我有一個隨機數組的布爾值的倒計時。問題是,每次它蜱總是創建數組和for循環。有人可以幫助我如何導入我的代碼在一個單獨的類和方法?我只是想在倒計時循環的時候調用數組的返回值。請幫助我,TIA! :)返回數組的方法
這是我的我的onCreate()裏面倒計時:
new CountDownTimer(300000, 1000) {
public void onTick(long msUntilFinished) {
txtCounter.setText("" + msUntilFinished/1000);
ImageView[] pic= {img1, img2, img3, img4, img5};
Random aRandom = new Random();
for (int i=0;i<12;i++){
arrays[i] = aRandom.nextBoolean();
if(arrays[i]){
pic[i].setImageResource(R.drawable.show);
appear = true;
} else {
pic[i].setImageResource(R.drawable.hide);
appear = false;
}
}
} // end of onTick
public void onFinish() {
txtCounter.setText("done!");
}
}.start();
你是在談論從另一個類的函數調用返回值或我缺少的東西嗎? – Kevin 2012-03-28 22:15:27
是的..我打算把我的數組放在一個單獨的類的函數中,並使用for循環通過倒計數方法調用它的索引。我仍然不熟悉方法調用,希望在這裏學習..順便說一句,感謝您的答覆。 – 2012-03-28 22:20:13