Android ListView,show a message if arrayList of arrayAdapter is empty

android

Solution

The common way is setting an empty textview (@android:id/empty) after the listview:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

<ListView
    android:id="@android:id/list"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:dividerHeight="1dp" >
</ListView>

<TextView 
    android:id="@android:id/empty"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/empty_list" />

</LinearLayout>

And then set set the empty view to the listview:

ListView lv = (ListView)findViewById(android.R.id.list);
TextView emptyText = (TextView)findViewById(android.R.id.empty);
lv.setEmptyView(emptyText);

This should show items in the list whenever they are, and show the textview when not.

Problem

I need help. I have a Listview.setListAdapter(arrayAdapter) and array adapter have a arrayList. If my arrayList is empty it shows loading images, it is normal, but how can i show a message if my arrayList is empty? Thanks in advance.

Original source