I have an ArrayAdapter associated with a ListView.
mListView.setAdapter(mArrayAdapter);
Whenever I reset ArrayList data in an ArrayAdapter:
mArrayAdapter.clear();
mArrayAdapter.addAll(mArrayList);
mArrayAdapter.notifyDataSetChanged()
ListView gets correct update
however, if right after the three lines above, I call my own method mListView.hasScrollbar()to determine if listview has a scrollbar or not, I get null lastVisibleItem:
public boolean hasScrollbar() {
View lastVisibleItem = (View) getChildAt(getChildCount() - 1);
if (lastVisibleItem.getBottom()>=getHeight()) {
return true;
}
return false;
}
Does this mean that listview is still refreshing?
My main question is:
how can I check if the listview has a scroll bar after resetting the adapter with new data?
Thank you for your help!