Gridview onScroll method gets called always, without user scroll -


i have customized gridview i'm checking onscroll method find end of list. if scroll reaches end of list, again add few elements in list.

gridview.setonscrolllistener(new onscrolllistener() {          @override         public void onscrollstatechanged(abslistview arg0, int arg1) {          }          @override         public void onscroll(abslistview arg0, int firstvisibleitem, int visibleitemcount, int totalitemcount) {             // todo auto-generated method stub              int lastinscreen = firstvisibleitem + visibleitemcount;                    //is bottom item visible & not loading more ? load more !             if((lastinscreen == totalitemcount) && (!loadingmore))             {                    new loaddatatask().execute();              }          }     }); 

and asynchronous task class..

    private class loaddatatask extends asynctask<void, void, void> {      @override     protected void doinbackground(void... params) {          if (iscancelled()) {             return null;         }         loadingmore = true;         (int = 0; < mnames.length; i++)             mlistitems.add(mnames[i]);          return null;     }      @override     protected void onpostexecute(void result) {         mlistitems.add("added after load more");            loadingmore=false;         adapter.notifydatasetchanged();         super.onpostexecute(result);     }      @override     protected void oncancelled() {      } } 

now issue onscroll method keep on calling. doesn't stop when user not scrolling. can have solution ?

please check answer question: onscroll gets called when set listview.onscrolllistener(this), without touch .

the same true gridview, since has abslistview superclass listview does.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -