Sunil Kumar Sahoo
Sunil Kumar Sahoo

Reputation: 53687

How to scrollable position in listview

Hi I have a listview with 11 elements. sometimes I want the user can scoll upto maximum 9th element and sometimes i want to scroll upto 5th element. So can we set maximum scroll position in listview depending on condition?

Thanks Sunil

Upvotes: 0

Views: 364

Answers (1)

Mark Allison
Mark Allison

Reputation: 21924

Why not create an OnTouchListener and attach it to your ListView. In the onTouch event, check whether the maximum position has been exceeded, and call scrollTo to prevent the scroll from going past the maximum.

Alternatively, you could simply modify your ListAdapter to sometimes only list 9 or 5 elements when you want to limit the scroll.

Upvotes: 1

Related Questions