Android: Cannot resolve method 'findFirstVisibleItemPosition()'? -


i'm trying write code endless scroll on recycler view. snippet gives me compiler error:

@override             public void onscrolled(recyclerview recyclerview, int dx, int dy) {                  visibleitemcount = mlayoutmanager.getchildcount();                 totalitemcount = mlayoutmanager.getitemcount();                 pastvisiblesitems = mlayoutmanager.findfirstvisibleitemposition();                  if ( (visibleitemcount+pastvisiblesitems) >= totalitemcount) {                     log.v("...", "last item wow !");                 } 

and declaration i've written before is:

mlayoutmanager = new linearlayoutmanager(this); 

and mlayoutmanager object of class recyclerview.layoutmanager

mlayoutmanager object of class recyclerview.layoutmanager wrong, should use android.support.v7.widget.linearlayoutmanager mlayoutmanager, so:

mlayoutmanager = new linearlayoutmanager(this);  //above 'linearlayoutmanager' //'android.support.v7.widget.linearlayoutmanager'  mrecyclerview.setlayoutmanager(mlayoutmanager); 

then mlayoutmanager.findfirstvisibleitemposition(); call should ok in onscrolled(...);.

hope help!


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -