Reputation: 153
I have a button below on my listview that allows the user to press it to auto-scroll back to the top of the list. I was wondering if there was a way to make it so that the button can visually scroll back to the top of the list instead of just jumping to the top. My current button code is as follows
ImageButton toTop = (ImageButton) findViewById(R.id.topButton);
toTop.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mListView.setSelection(0);
mListView.requestFocus(0);
v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
}
});
Upvotes: 0
Views: 31
Reputation: 6697
Its simple,Android provides method for this..
mListView.smoothScrollToPosition(0);
Upvotes: 1