Reputation: 4316
Is there an elegant way to ask a ListView how many list items currently fit on the screen?
Or the other way around: Is is possible to tell a ListView to make its list items that big (by increasing their height) that exactly n items fit on the screen? In my case the list items are simple TextViews.
Upvotes: 1
Views: 436
Reputation: 1094
YOU can use list.getLastVisiblePosition()
and subtract list.getFirstVisiblePosition()
int count = list.getLastVisiblePosition() - list.getFirstVisiblePosition();
Hope this helps
Upvotes: 2
Reputation: 7985
Easiest way is to do this is probably get your ListView
height and create your own View that measures itself to be listView.getHeight()/N
(where n is the number of views you want on screen at once).
Upvotes: 2