android - How do I check when my ListView has finished redrawing? -


i have listview. updated adapter, , call notifydatasetchanged(). want wait until list finishes drawing , call getlastvisibleposition() on list check last item.

calling getlastvisibleposition() right after notifydatasetchanged() doesn't work because list hasnt finished drawing yet.

hopefully can help:

  • setup addonlayoutchangelistener on listview
  • call .notifydatasetchanged();
  • this fire off onlayoutchangelistener once completed
  • remove listener
  • perform code on update (getlastvisibleposition())

    mlistview.addonlayoutchangelistener(new view.onlayoutchangelistener() {    @override public void onlayoutchange(view v, int left, int top, int right, int bottom, int oldleft, int oldtop, int oldright, int oldbottom) {     mlistview.removeonlayoutchangelistener(this);     log.e(tag, "updated");   } });  madapter.notifydatasetchanged(); 

Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -