Saturday, 15 August 2015

android - ListView comes to first position again after scrolling -



android - ListView comes to first position again after scrolling -

hi have listview in application after scrolling bottom 1 time again sets first position.

listview = (listview) findviewbyid(r.id.list); start = listview.getfirstvisibleposition(); listview.setselectionfromtop(start, 0);

after removing next code works fine after scrolling setonitemclicklistener not work.

listview.setonscrolllistener(new onscrolllistener() { public void onscrollstatechanged(abslistview view, int scrollstate) { if ( scrollstate == onscrolllistener.scroll_state_idle ) { listview.invalidateviews(); } } @override public void onscroll(abslistview arg0, int arg1, int arg2, int arg3) {} });

any suggestion appreciated. in advance

try way,hope help solve problem.

listview.setonscrolllistener(new abslistview.onscrolllistener() { @override public void onscrollstatechanged(abslistview view, int scrollstate) { } @override public void onscroll(abslistview view, int firstvisibleitem, int visibleitemcount, int totalitemcount) { int lastinscreen = firstvisibleitem + visibleitemcount; if((lastinscreen == totalitemcount)){ new handler().postdelayed(new runnable() { @override public void run() { listview.smoothscrolltoposition(0); } },1000); // alter (1000) value per requirement : when list shown lastly item after 1 sec list scrolled 0 position } } });

android

No comments:

Post a Comment