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
Post a Comment