Reputation: 7624
The following callbacks are implemented for the seekbar:
void onProgressChanged(Seekbar seekBar, int progress, boolean fromTouch);
void onStartTrackingTouch(Seekbar seekBar);
void onStopTrackingTouch(Seekbar seekBar);
But what callback is received when OK is pressed on the seekbar?
onStartTrackingTouch() is received when the user has just started to move the seekbar. onStopTrackingTouch() is received when user has finished moving the seekbar. Am i correct in these definitions or are these two callbacks for something else?
Could someone help with these two queries? Thanks
Upvotes: 0
Views: 1127
Reputation: 7081
What do you mean
But what callback is received when OK is pressed on the seekbar?
Do you have a ok button that should implement something? If so you can use a integer value to save the progress when the progress is changed and then when you press the ok button you can execute whatever you want. Look at this example
seekerSpacing.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
doSomethingAfterTracking();
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
doSomethingWhenTrackingStarts();
}
/**
* seekBar The SeekBar whose progress has changed
* progress The current progress level. This will be in the range 0..max where max was set by setMax(int). (The default value for max is 100.)
* fromUser True if the progress change was initiated by the user.
*/
@Override
public void onProgressChanged(SeekBar seekBar, int progress,
boolean fromUser) {
setMyCurrentProgress(progress);
doSomeOtherMethodIfRequired();
}
});
You can have a look at the Android docs for the correct explanations. But here is a quick summary.
The onStartTrackingTouch
method is invoked as soon as you touch the seekbar. This method will always be invoked when you touch the seekbar slider
The onStopTrackingTouch
method is invoked as soon as you let go of the seekbar. This method will always be invoked when you let go of the seekbar slider.
The onProgressChanged
method is invoked as soon as the progress of the seekbar is changed. This method will only be invoked when the progress changes
Upvotes: 1