错误:找不到符号方法findFirstVisibleItemPosition()

时间:2016-05-26 18:16:50

标签: android

我认为我的代码没问题,但出于某种原因,我有这个错误。这是我的代码:

recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener()
    {
        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy)
        {
            if(dy > 0) //check for scroll down
            {
                visibleItemCount = mLayoutManager.getChildCount();
                totalItemCount = mLayoutManager.getItemCount();
                pastVisiblesItems = mLayoutManager.findFirstVisibleItemPosition();

                if (loading)
                {
                    if ( (visibleItemCount + pastVisiblesItems) >= totalItemCount)
                    {
                        loading = false;
                        Log.v("...", "Last Item Wow !");
                        //Do pagination.. i.e. fetch new data
                    }
                }
            }
        }
    });

我已经导入了android.support.v7.widget.LinearLayoutManager并且已经删除了

private RecyclerView recyclerView;
private RecyclerView.LayoutManager mLayoutManager;

1 个答案:

答案 0 :(得分:2)

因为data.table中没有类似library(data.table) rbind(setDT(df)[, .(side = 'avg', value=mean(value)) , .(subject_id, area, confound1, confound2, confound3)][, names(df), with=FALSE], df)[order(subject_id, area, factor(side, levels=c('left', 'right', 'ave')))] # subject_id area side value confound1 confound2 confound3 # 1: s01 A left 5.0 154 952 no # 2: s01 A right 7.0 154 952 no # 3: s01 A avg 6.0 154 952 no # 4: s01 B left 15.0 154 952 no # 5: s01 B right 17.0 154 952 no # 6: s01 B avg 16.0 154 952 no # 7: s02 A left 3.0 130 870 yes # 8: s02 A right 5.0 130 870 yes # 9: s02 A avg 4.0 130 870 yes #10: s02 B left 12.0 130 870 yes #11: s02 B right 11.0 130 870 yes #12: s02 B avg 11.5 130 870 yes 的方法(参见documentation)。您需要使用LinearLayoutManager来使用findFirstVisibleItemPosition
从此

更改您的声明
findFirstVisibleItemPosition

到这个

RecyclerView.LayoutManager