i have a listview in a fragment(Total 3 tabs in viewpager) and using this below code to get swipe down to refresh functionality but on swiping left to another fragment swipe refresh function is called how to restrict this(happens only if listview is empty).
Java code
Code:
<RelativeLayout 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"
>
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/fragmenttab1_swipe_refresh_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/fragmenttab1_list_item"
android:dividerHeight="1dp"
android:focusable="false"
android:focusableInTouchMode="false"
android:longClickable="true">
</ListView>
</android.support.v4.widget.SwipeRefreshLayout>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/fragmenttab1_emptyElement"
android:text="No Posts"
android:textStyle="bold"
android:textSize="15sp"
android:visibility="gone"
android:layout_centerInParent="true"
android:textColor="@android:color/darker_gray"/>
</RelativeLayout>
Code:
listView.setAdapter(adapter);
listView.setEmptyView(getView().findViewById(R.id.fragmenttab1_emptyElement));
Last edited: