question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Swipe refresh not working if list is empty

See original GitHub issue

Pulling down is not working if there are no items and the empty view is shown.

Investigate android/support/v4/widget/SwipeRefreshLayout.java.

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
rothschild86commented, Dec 20, 2014

thanks for documenting this!

2reactions
UweTrottmanncommented, Jul 5, 2014

OK, turns out the SwipeRefreshLayout intercepts touch MOVE events (see its onTouchEvent). A regular non-scrollable view/view group won’t trigger these.

Solution: wrap empty view into a ScrollView. Stick both AdapterView and the ScrollView into a ViewGroup and put it into the SwipeRefreshLayout.

<android.support.v4.widget.SwipeRefreshLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <ListView
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

        <ScrollView
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <TextView
                android:layout_width="250dp"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:gravity="center" />

        </ScrollView>

    </FrameLayout>

</android.support.v4.widget.SwipeRefreshLayout>

Then override canChildScrollUp() to check the adapter view or scroll view, depending on which one is visible at the time.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Android SwipeRefreshLayout with empty TextView not ...
The problem is that if you set tv_no_product as emptyView for the ListView, then the ListView sets its visibility to GONE while the...
Read more >
Swipe Refresh for Jetpack Compose
A library which provides a layout which provides the swipe-to-refresh UX pattern, similar to Android's SwipeRefreshLayout . Your browser does not support the ......
Read more >
SwipeRefreshLayout indicator does not shown [37007421]
Empty view is for empty list, having a separate loading indicator and a swipe-to-refresh indicator is problematic to code and may confuse the...
Read more >
drag down refresh functionality using SwipeRefreshLayout in ...
How to implement swipe/ drag down refresh functionality using SwipeRefreshLayout in the Android App?
Read more >
pull_to_refresh | Flutter Package - Pub.dev
This problem can only wait for flutter to fix this. SmartRefresher does not have refresh injection into ScrollView under the subtree, that is,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found