@Override protected void onAttachedToWindow() { super.onAttachedToWindow(); // 被添加到窗口后再设置监听器,这样开发者就不必烦恼先初始化RefreshLayout还是先设置自定义滚动监听器 if (!mIsInitedContentViewScrollListener && mLoadMoreFooterView != null) { setRecyclerViewOnScrollListener(); setAbsListViewOnScrollListener(); addView(mLoadMoreFooterView, getChildCount()); mIsInitedContentViewScrollListener = true; } }