How to increase the value of the search bar

I want to create a search panel, which is divided into 5 sections, below Average Average and Excellent , for each step I want to increase the way this arrow Default = 0 maximum value = 100;

 i want seek bar values like this :0,25,50,75,100 

how can i achieve this.

thanks

+4
source share
3 answers

You just need to update the onProgressChanged method as follows.

 int yourStep = 25; public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { progress = ((int)Math.round(progress/yourStep ))*yourStep; seekBar.setProgress(progress); textview.setText(progress + ""); } 

We hope for his help

UPD

I think in your xml you set android:max="100" for your SeekBar . But you need to set android:max="101" , because between points 0 and 100 = 101 .

just replace

 android:max="100" 

for

 android:max="101" 
+18
source

Try the following:

 seekBar.setProgress(4); 

This will give the values 0, 1, 2, 3, 4 . You do not need to play with onProgressChanged , just multiply by 25 and you have the values 0, 25, 50, 75, 100 .

+2
source

Try using the following code.

 seekBar.setProgress(YOUR_VALUE); 
0
source

All Articles