How to toggle Android ListView Empty Text?

Viewed 11275

So I have a ListView with an empty list catch in the XML. It works fine. I set the TextView on the ID to be the empty list for different cases, so I need to be able to programatically change that text.

<ListView
    android:id="@android:id/list"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
/>
<TextView android:id="@android:id/empty"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/no_data"
/>

I would like to have something like this but it won't work:

TextView empty = (TextView)listing.findViewById(android.R.id.empty);
empty.setText(R.string.no_display_data);

Any ideas?

3 Answers
Related