Pergunta

I have tried seekbar normal task to display the time from 1 to 12 but I have little different requirement. enter image description here

please some body can help me to get seekbar show value exactly like this.

Foi útil?

Solução

your seek bar have a range from min to max. You must define what range you need. For example you want to choose date with seek bar from 0:00 to 23:59 with step of 15 minutes. So you need range bar with min = 0 and max = 24 * 4. When your seek bar is changed you need to calculate actual selected time. For that, you can get SeekBar progress and multiply it to 15 minutes. And you will get selected minutes.

Example code:

seekBar.setMax(24 * 4); //24 hours and 4 step in one hour.

seekBar.setOnSeekBarChangeListener(new OnSeekBarChangetListener() {
  public void onProgressChanged (SeekBar seekBar, int progress, boolean fromUser) {
     int hours = progress / 4; // it will return hours.
     int minutes = (progress % 4) * 15; // here will be minutes.
  }
});

hope this helps

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top