Android: Cannot resolve method 'findFirstVisibleItemPosition()'?

后端 未结 1 1837
星月不相逢
星月不相逢 2020-12-11 18:02

I\'m trying to write a code for endless scroll on a recycler view. This is the snippet that gives me a compiler error:

@Override
            public void onSc         


        
相关标签:
1条回答
  • 2020-12-11 18:13

    mLayoutManager is an object of class RecyclerView.LayoutManager is wrong, you should use android.support.v7.widget.LinearLayoutManager for mLayoutManager, so:

    mLayoutManager = new LinearLayoutManager(this); 
    //above 'LinearLayoutManager' is from
    //'android.support.v7.widget.LinearLayoutManager'
    
    mRecyclerView.setLayoutManager(mLayoutManager);
    

    then mLayoutManager.findFirstVisibleItemPosition(); call should be ok in onScrolled(...);.

    Hope this help!

    0 讨论(0)
提交回复
热议问题