Changing step values in seekbar?

前端 未结 8 1967
耶瑟儿~
耶瑟儿~ 2020-12-12 16:32

I have a seekbar, while moving it I want to change values from 0 to 200. I have a TextView, where I display those values while moving the seekbar. But I don\'t want to have

8条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-12 17:01

    You should use the SeekBar.OnSeekBarChangeListener for tracking the progress change. Call mseek.setMax(200). Do a modulo operation on the current value to decide if the textview should be updated or not.

    SeekBar.OnSeekBarChangeListener() {
    
        void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            if (progress % 10 == 0) {
                textview.setText(""+progress);
            }
        }
    }
    

提交回复
热议问题