Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scroll up force SwipeRefreshLayout to refresh #57

Open
tolotrasam opened this issue Mar 11, 2017 · 2 comments
Open

Scroll up force SwipeRefreshLayout to refresh #57

tolotrasam opened this issue Mar 11, 2017 · 2 comments

Comments

@tolotrasam
Copy link

Scroll up force SwipeRefreshLayout to refresh, however, scroll down works properlly

@nmvictor
Copy link

nmvictor commented Jan 28, 2019

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());
...

@grossmae
Copy link

@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);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
@nmvictor @grossmae @tolotrasam and others