我有for loop
:
for(int i = 1 ; i <= right_num ; i++ ){
for(int u = 1 ; u <= left_num ; u++ ){
int resourceId = this.getResources().getIdentifier("c"+u+"_r"+i, "id", this.getPackageName());
ImageButton imageButton = (ImageButton) findViewById(resourceId);
imageButton.setBackgroundResource(R.drawable.white_circle);
}
}
我希望将其转换为Timer Schedule
,并在更改250 ms
之间设置时间。
怎么做?
答案 0 :(得分:0)
试试这个:
int i=0;
int total_time=250*left_num*right_num;
private CountDownTimer counter = new CountDownTimer(total_time, 250) {
public void onTick(long millisUntilFinished) {
int u=i%left_num+1,v=i/left_num+1;
int resourceId = this.getResources().getIdentifier("c"+u+"_r"+v, "id", this.getPackageName());
ImageButton imageButton = (ImageButton) findViewById(resourceId);
imageButton.setBackgroundResource(R.drawable.white_circle);
i++;
}
public void onFinish() {
}
};
如果有帮助请告诉我