我想結合使用一種方法移動手的方法runSec
和runMin
。這些方法在時鐘面上移動分鐘和秒針幫助,謝謝。如何將類似的方法合併爲一個
public void settTime(int seconds) {
if(isTimer)
return;
tTime = seconds;
int minutes = seconds/60;
int hours = minutes/60;
minutes = minutes % 60;
seconds = seconds % 60;
tTimeLabel.setText(String.format("%02d:%02d:%02d", hours, minutes, seconds));
runSec(seconds);
runMin(minutes);
}
public void runSec(int seconds) {
RotateAnimation rotateAnimation = new RotateAnimation(seconds * 6, seconds * 6,
Animation.RELATIVE_TO_SELF, 0.5f,Animation.RELATIVE_TO_SELF, 0.5f);
rotateAnimation.setFillAfter(true);
csecond.startAnimation(rotateAnimation);
}
public void runMin(int minutes) {
RotateAnimation rotateAnimation = new RotateAnimation(minutes * 6, minutes * 6,
Animation.RELATIVE_TO_SELF, 0.5f,Animation.RELATIVE_TO_SELF, 0.5f);
rotateAnimation.setFillAfter(true);
cminute.startAnimation(rotateAnimation);
}
對不起,我不明白問題 – Entreco