android - Find if a ListView is scrolled "fully" to the bottom? -


what want

i want detect if listview have been scrolled "fully" bottom. word "fully", mean last element of list should visible.

what did

this did.

list.setonscrolllistener(new abslistview.onscrolllistener() {                     @override                     public void onscrollstatechanged(abslistview view, int scrollstate) {                      }                      @override                     public void onscroll(abslistview view, int firstvisibleitem, int visibleitemcount, int totalitemcount) {                          switch (view.getid()) {                             case r.id.enclist:                                  final int lastitem = firstvisibleitem + visibleitemcount;                                 if (lastitem == totalitemcount) {                                      if (prelast != lastitem) { //to avoid multiple calls last item                                         log.d("log", "last reached");                                         prelast = lastitem;                                     }                                 } else                                     prelast = lastitem;                         }                      }                 }); 

the problem

my code works extent doesn't provide exact result wish for. log gets printed when last element visible, want printed when last element visible.

what modifications need in code?

put this

if (list.getlastvisibleposition() ==  list.getadapter().getcount() -1 &&  list.getchildat(list.getchildcount() - 1).getbottom() <= list.getheight()){ //scrolled end } 

in onscroll


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -