I have seen many tutorial and other things here to set the empty view when the list is empty. I have a list that is able to swipe to refresh. Now I want to show a text message in a text view when the list view is null. I have come to know that it can be simple set lik this
myListview.setEmptyView(mEmptyViewContainer);
but it is not setting the textview when the data is null in the listview. The following is the modification of my xml after reading an issue which he resolved by wrapping the text view in the separate swipeRefreshLayout . Just see below, this is my xml now
<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:background="#dadada"
>
<RelativeLayout
android:layout_width="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
>
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/swipe_refresh_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<com.baoyz.swipemenulistview.SwipeMenuListView
android:id="@+id/listView"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</android.support.v4.widget.SwipeRefreshLayout>
</RelativeLayout>
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/swipeRefreshLayout_emptyView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@android:id/empty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="sdasdadadfdasf"
android:layout_centerInParent="true"
android:visibility="gone"
android:gravity="center"
/></ScrollView>
</android.support.v4.widget.SwipeRefreshLayout>
</RelativeLayout>
So now I do not understand why it is not showing my empty view? what can be the problem ? Or please tell me if there is another way to do this? the code snippet would be appreciated.