How do you know if your ListView has enough number of items so that it can scroll?
For instance, If I have 5 items on my ListView all of it will be displayed on a si
You cannot detect this before android render the screen with the listView
. However, you can absolutely detect this post-render.
boolean willMyListScroll() {
if(listView.getLastVisiblePosition() + 1 == listView.getCount()) {
return false;
}
return true;
}
What this does is check if the listView
visible window contains ALL your list view items. If it can, then the listView
will never scroll and the getLastVisiblePosition()
will always be equal to the total number of items in the list's dataAdapter.
Use the setOnScrollListener, by applying the callback to OnScrollListener, you can determine if scrolling is taking place using the pre-defined constants and handle the situation accordingly.