Istview.getcount () (actually Adapterview.getcount ()) returns the value returned by its adapter.getcount (). That is, the total number of items contained in the Item.
Listview.getchildcount () (Viewgroup.getchildcount) returns the "number of child View contained" on the display plane.
What's the difference between the two? When the item in the ListView is less than scrolling to show it all, the two are equivalent; Getchildcount () < GetCount () where the item number needs scrolling to view all of them Getchildcoun T () returns the Item count that is currently visible.
Java code
Listview.setonscrolllistener (New Onscrolllistener () {
@Override
public void onscrollstatechanged (Abslistview view, int scrollstate) {
TODO auto-generated Method Stub
}
@Override
public void Onscroll (Abslistview view, int firstvisibleitem,
int visibleitemcount, int totalitemcount) {
TODO auto-generated Method Stub
/**firstvisibleitem in the current screen the first ListItem (partially displayed ListItem also counted)
Position throughout the ListView (subscript starting from 0) **/
LOG.I ("Firstvisibleitem", String.valueof (Firstvisibleitem));
/**visibleitemcount indicates the total number of ListItem (ListItem in part) that can be seen on the current screen **/
LOG.I ("VisibleItemCount", String.valueof (VisibleItemCount));
/**totalitemcount represents the total number of ListItem in the ListView **/
LOG.I ("Totalitemcount", String.valueof (Totalitemcount));
/**listview.getfirstvisibleposition () indicates that the first listitem of the screen (the first ListItem part of the display is counted)
* position in the entire ListView (subscript starting from 0) **/
LOG.I ("Firstposition", String.valueof (Listview.getfirstvisibleposition ()));
/**listview.getlastvisibleposition () in the current screen at the last ListItem (the last ListItem to be fully displayed in order to calculate)
* position in the entire ListView (subscript starting from 0) **/
LOG.I ("Lasposition", String.valueof (Listview.getlastvisibleposition ()));
}
});
Differences between Listview.getcount () and Listview.getchildcount () and Onscrolllistener () parameters in Android