在SeekBar的监听器中,当拖动任意一个SeekBar时,遍历所有的SeekBar,将它们的进度设置为0。具体的代码实现示例如下:
SeekBar seekBar1 = findViewById(R.id.seekBar1);
SeekBar seekBar2 = findViewById(R.id.seekBar2);
SeekBar seekBar3 = findViewById(R.id.seekBar3);
// 设置SeekBar的监听器
SeekBar.OnSeekBarChangeListener seekBarChangeListener = new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
// 当拖动任意一个SeekBar时,将所有SeekBar的进度设置为0
if (fromUser) {
seekBar1.setProgress(0);
seekBar2.setProgress(0);
seekBar3.setProgress(0);
}
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
};
// 给每个SeekBar设置监听器
seekBar1.setOnSeekBarChangeListener(seekBarChangeListener);
seekBar2.setOnSeekBarChangeListener(seekBarChangeListener);
seekBar3.setOnSeekBarChangeListener(seekBarChangeListener);