I am using the stock SeekBar component to navigate through a set of ViewPagers and it's working quite fine. Only problem is that when the data changes, I have to dynamically change the max value of the SeekBar via setMax(int value). When I do that, the SeekBar does not get updated until I navigate to a new page. I have a hacky fix in place where I do this, to force a onProgressChanged:
seekBarVP.setProgress(focusedPage+1);
seekBarVP.setProgress(focusedPage-1);
seekBarVP.setProgress(focusedPage);
Is there a better way to do this?
setOnSeekBarChangeListener(new OnSeekBarChangeListener() { @Override public void onStopTrackingTouch(SeekBar seekBar) { // TODO Auto-generated method stub //int inVal = Integer. parseInt(String. valueOf(seekBar. getProgress())); //inVal =+ 70; //Toast.
In Order to the seekBar to Change while you are in the Activity you need to Call the method setProgress(), and pass it a boolean animate value.
In Android, SeekBar is an extension of ProgressBar that adds a draggable thumb, a user can touch the thumb and drag left or right to set the value for current progress.
Step1: Create a new project. After that, you will have java and XML file. Step2: Open your xml file and add a SeekBar and TextView for message as shown below, max attribute in SeekBar define the maximum it can take. Assign ID to SeekBar And TextView.
Create updateThumb(); method in VerticalSeekbar
public void updateThumb(){
onSizeChanged(getWidth(), getHeight(), 0, 0);
}
And then call update thumb method after setting progress.
seekBar.setProgress((int) progress);
seekBar.updateThumb();
its work for me in verticalseekbar calss
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With