Skip to content

Instantly share code, notes, and snippets.

@JetXing
Created March 23, 2015 04:14
Show Gist options
  • Save JetXing/11c62043dd7ce9a4f29b to your computer and use it in GitHub Desktop.
Save JetXing/11c62043dd7ce9a4f29b to your computer and use it in GitHub Desktop.
解决SwipeRefreshLayout嵌套ListView时,滑动ListView触发SwipeRefreshLayout的refresh method
/**
* 解决listview向上滑动刷新的bug
*/
mListView.setOnScrollListener(new AbsListView.OnScrollListener() {
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
}
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
int topRowVerticalPosition = (mListView == null || mListView.getChildCount() == 0) ? 0 : mListView.getChildAt(0).getTop();
mRefreshLayout.setEnabled(firstVisibleItem == 0 && topRowVerticalPosition >= 0);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment