Android: Detect if a ListView has the scrollbar (after setting new data)
问题 I have an ArrayAdapter linked to a ListView. mListView.setAdapter(mArrayAdapter); Whenever I reset the ArrayList data to the ArrayAdapter: mArrayAdapter.clear(); mArrayAdapter.addAll(mArrayList); mArrayAdapter.notifyDataSetChanged() the ListView gets correctly updated however, if just after the above three lines, I call my custom method mListView.hasScrollbar() to detect whether the listview has a scrollbar or not, I get a null lastVisibleItem : public boolean hasScrollbar() { View