我正在尝试使用 SeekBar 来控制 CountDownTimer 的速度,并且我在 2 个问题中停止了。1 - 当我更改搜索栏进度时,DownTimerInterval 不会重置......但每次我更改时都会添加进度值。2 - 当搜索栏进度设置为 0 时,我想停止倒计时......但它不起作用。如何解决?
这是我的代码
rolagem.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
rolagemAutomatica();
}
});
private void rolagemAutomatica() {
barra = (SeekBar)findViewById(R.exibir_musica.barraFonte);
barra.setVisibility(1);
barra.setMax(4);
barra.setProgress(0);
barra.setOnSeekBarChangeListener( new SeekBar.OnSeekBarChangeListener() {
public void onStopTrackingTouch(SeekBar seekBar) {
}
public void onStartTrackingTouch(SeekBar seekBar) {
}
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
String[] VR = {"0","10","50","75","100"};
//Define crono +1 cause position 0 crash the app
int crono = Integer.parseInt(VR[progress]+1);
CountDownTimer test = new CountDownTimer(400000 , crono) {
@Override
public void onTick(long millisUntilFinished) {
scroll_letra.smoothScrollBy(0,
(int) (millisUntilFinished / 300000));
}
@Override
public void onFinish() {
// TODO Auto-generated method stub
}
};
if(crono-1 != 0){
test.start();
}else{
test.cancel();
}
}
});
}