我正在使用两个进度轮。在那,完成进度后,我如何重置第一个进度轮并启动第二个?我的代码:
final Runnable r = new Runnable() {
public void run() {
running = true;
while(progress<361) {
pw_two.incrementProgress();
progress++;
try {
Thread.sleep(5);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
progress = 0;
while(progress<361) {
pw_one.incrementProgress();
progress++;
try {
Thread.sleep(5);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
progress = 0;
running = false;
}
};
它通过单击按钮重置。但我需要在线程完成后重置。
Button increment = (Button) findViewById(R.id.btn_increment);
increment.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
if(!running) {
pw_two.resetCount();
pw_one.resetCount();
Thread s = new Thread(r);
s.start();
}
}
});