I'm having an issue with the SwipeRefreshLayout. I have a list view within the layout and every time I scroll upward in the list view the swipe to refresh layout is tiggered and you can never scroll back to the top of the layout. Anyone have any ideas?
I found an answer to my question. I am manually enabling the swipeRefreshLayout when the first child in the listview is at the top of the list.
listView.setOnScrollListener(new AbsListView.OnScrollListener() {
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
}
@Override
public void onScroll(AbsListView listView, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
int topRowVerticalPosition = (listView == null || listView.getChildCount() == 0) ?
0 : expandableListview.getChildAt(0).getTop();
refresh.setEnabled((topRowVerticalPosition >= 0));
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With