且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

安卓:无法解析法“findFirstVisibleItemPosition()”?

更新时间:2023-02-26 21:44:08

mLayoutManager是类RecyclerView.LayoutManager的对象是不对的,你应该使用 android.support.v7.widget.LinearLayoutManager mLayoutManager ,这样:

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);

然后 mLayoutManager.findFirstVisibleItemPosition(); 调用应该是确定的 onScrolled(...);

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

希望这有助于!