HeaderListView
HeaderListView copied to clipboard
Scroll up force SwipeRefreshLayout to refresh
Scroll up force SwipeRefreshLayout to refresh, however, scroll down works properlly
how I went about this was to add my SwipeRefreshLayout in HeaderListView manually and then add the internal ListView to mySwipeRefreshLayout
...
mListView.setOnItemClickListener((parent, view, position, id) -> {
if (mAdapter != null) {
mAdapter.onItemClick(parent, view, position, id);
}
});
mSwipeRefreshLayout = new SwipeRefreshLayout(getContext());
LayoutParams swipeParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
swipeParams.addRule(ALIGN_PARENT_TOP);
mSwipeRefreshLayout.setLayoutParams(listParams);
mSwipeRefreshLayout.addView(mListView);
addView(mSwipeRefreshLayout);
mHeader = new RelativeLayout(getContext());
...
@nmvictor 's solution worked for me but for clarity it was necessary to remove the internal ListView from its parent.
ListView interalListView = headerListView.getListView();
headerListView.removeView(internalListView);
swipeRefreshLayout.addView(internalListView);