I am using a ListView
and refreshing it when swiping down with SwipeRefresh
, it works fine till here. The problem occurs when I try to set a TextView
on mListview.setEmptyView()
the Refresh Icon
is not shown while swiping.
It looks like it is under the TextView
. However if I don't put that TextView
on the same XML it works fine, but I need to show a message when a list is empty. What is causing this behaviour?
Here is the layout I use:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingLeft="@dimen/padding_light"
android:paddingRight="@dimen/padding_light">
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipeRefreshLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true">
<ListView
android:id="@+id/mListView"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</android.support.v4.widget.SwipeRefreshLayout>
<TextView
android:id="@+id/swipeToRefreshTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="15dp"
android:gravity="center_horizontal"
android:text="@string/msg_swipe_to_refresh"
android:visibility="gone" />
</RelativeLayout>
Here is the Refresh listener:
//Listeners
mSwipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
//Here I do some job
beaconScanSwipeRefresh.setRefreshing(false);
}
});
Here is where I set the adapter of ListView
and onEmptyView:
//UI
mListLv = (ListView) view.findViewById(R.id.mListView);
mSwipeRefresh=(SwipeRefreshLayout)view.findViewById(R.id.swipeRefreshLayout);
swipeToRefreshTv = (TextView)view.findViewById(R.id.swipeToRefreshTextView);
//Set Adapter
mListLv.setAdapter(mBaseAdapter);
//Set Message when list is empty
mListLv.setEmptyView(swipeToRefreshTv);
I have tried to move my TextView
inside <android.support.v4.widget.SwipeRefreshLayout
tags or above them. Still same result.