Is there a callback for when RecyclerView has finished showing its items after I've set it with an adapter?

前端 未结 3 1364
心在旅途
心在旅途 2020-12-02 12:56

Background

I\'ve made a library that shows a fast-scroller for RecyclerView (here, in case anyone wants), and I want to decide when to show and when to hide the fa

3条回答
  •  盖世英雄少女心
    2020-12-02 13:30

    Leaving this here as an alternate approach. Might be useful in some cases. You can also make use of the LinearLayoutManagers onScrollStateChanged() and check when the scroll is idle.

    One thing to remember, when you load your view for the 1st time, this will not be called, only when the user starts scrolling and the scroll completes, will this be triggered.

    LinearLayoutManager layoutManager = new LinearLayoutManager(getContext(),
                    RecyclerView.HORIZONTAL, false) {
    
                @Override
                public void onScrollStateChanged(int state) {
                    super.onScrollStateChanged(state);
    
                    if (state == RecyclerView.SCROLL_STATE_IDLE) {
                            // your logic goes here
                        }
                    }
                }
            };
    

提交回复
热议问题