Reputation:
I have a listview and a seekbar, i want the listview to react accroding to the interaction with the seekbar.
For ex :- if the seekbar is dragged to either ends, the listview should automatically go up or down.
Any help is greatly appreciated.
Upvotes: 0
Views: 282
Reputation: 161
You should be able to use the list view method: smoothScrollToPosition(int) and OnSeekBarChangeListener
Set an OnSeekBarChangeListener on your seekbar. In onProgressChanged add code using smoothScrollToPosition to update the listvew position. Something like this:
public void onProgressChanged (SeekBar seekBar, int progress, boolean fromUser) {
listView.smoothScrollToPosition(progress); //assuming you have a 1 seekbar position for each row in the list, otherwise you'll need to do some calculation to compute the new list view position.
}
alternatively, you could use the onStopTrackingTouch method if you only want to scroll to the final position the user touched in the seekbar.
Upvotes: 1