I have this SwipeRefreshLayout XML code:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.SwipeRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/swipeContainer"
xmlns:design="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:weightSum="1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:theme="@style/Theme.AppCompat"
tools:context="com.tag.instagramdemo.example.MainActivity"
android:background="@drawable/background1">
<android.support.design.widget.CoordinatorLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/lvRelationShip2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<EditText
android:id="@+id/txtsearch"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="Search" />
<ListView
android:id="@+id/lvRelationShip"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</ListView>
</LinearLayout>
<TableLayout
android:id="@+id/table1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_gravity="bottom"
android:stretchColumns="0,1,2">
<TableRow
android:id="@+id/tableRowFive"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<ImageView
android:adjustViewBounds="true"
android:maxHeight="40dp"
android:maxWidth="40dp"
android:scaleType="fitCenter"
android:src="@drawable/arrow" />
<TextView
android:layout_gravity="center_horizontal|bottom"
android:text="Click To View"
android:textSize="26dp" />
<ImageView
android:adjustViewBounds="true"
android:maxHeight="40dp"
android:maxWidth="40dp"
android:scaleType="fitCenter"
android:src="@drawable/arrow2" />
</TableRow>
<android.support.design.widget.BottomNavigationView xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/bottomBar"
android:layout_width="match_parent"
android:layout_height="64dp"
android:layout_gravity="bottom"
android:animateLayoutChanges="true"
android:background="#ffffff"
android:clickable="false"
android:contextClickable="false"
android:enabled="false"
app:itemIconTint="@color/text"
app:itemTextColor="@color/text"
design:menu="@menu/menu_main" />
</TableLayout>
</android.support.design.widget.CoordinatorLayout>
</android.support.v4.widget.SwipeRefreshLayout>
Notice that I have this ListView with the ID: lvRelationShip.
In this SwipeRefresh XML file, I want the action of refreshing only to trigger when I scroll to the top of the ListView.
Problem: In the ListView when I scroll down to see other items in the list everything is fine, but when I scroll up to see previous Items, the page just refreshes. I want the list to only refresh when I scroll up at the top of the list.