Created
March 23, 2015 04:14
-
-
Save JetXing/11c62043dd7ce9a4f29b to your computer and use it in GitHub Desktop.
解决SwipeRefreshLayout嵌套ListView时,滑动ListView触发SwipeRefreshLayout的refresh method
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 解决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