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

node.js - How to mock a third-party api calls in the backend -

node.js - Why do I get "SOCKS connection failed. Connection not allowed by ruleset" for some .onion sites? -

matlab - 0-by-1 sym - What do I need to change in order to get proper symbolic results? -