3

I have an app with a SwipeRefreshLayout which has a ListView inside it. When the ListView is populated, I can easily scroll down to read the older items on the list, but when I try to scroll up this action is mistaken for a Pull2Refresh action even though I am trying to scroll up. It does not matter where I position my finger it still mistakes this for a Pull2Refresh action. How can I sort this problem as scrolling back to the top is a problem.

Here is the XML to that fragment with the SwipeRefreshLayout :

<android.support.v4.widget.SwipeRefreshLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/swipe_refresh_layout_general"
  android:layout_width="match_parent"
  android:layout_height="wrap_content">

  <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.inc.automata.unamupdates.fragments.GeneralNewsFragment">

    <ListView
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:id="@+id/listViewGeneral">
    </ListView>
  </FrameLayout>
</android.support.v4.widget.SwipeRefreshLayout>
Rich
  • 1,015
  • 1
  • 10
  • 22
Manny265
  • 1,709
  • 4
  • 23
  • 42
  • 4
    Does this answer your question? [When I am scrolling up SwipeRefreshLayout refreshing my app](https://stackoverflow.com/questions/36281497/when-i-am-scrolling-up-swiperefreshlayout-refreshing-my-app) – Kalana Dec 10 '19 at 09:03

2 Answers2

4

The problem is that you have wrapped your whole layout with the swipe refresh layout. You should only wrap your ListView with the SwipeRefreshLayout. Link to original answer

 <android.support.v4.widget.SwipeRefreshLayout
...
>
    <RecyclerView 
     ...
    />
</android.support.v4.widget.SwipeRefreshLayout>
Yonko Kilasi
  • 337
  • 3
  • 9
-2

try to Use follwoing attributes in listview

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.inc.automata.unamupdates.fragments.GeneralNewsFragment">

    <ListView
        android:id="@+id/listViewGeneral"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:smoothScrollbar="true"
        android:fadeScrollbars="true"></ListView>

</FrameLayout>

Nitesh Pareek
  • 362
  • 2
  • 10