Reputation: 351
So I have a ListView
in a Fragment
on which I run listView.setEmptyView(getActivity().findViewById(R.id.emptyListView));
In my xml file I have
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/listView_main" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Nothing here yet! "
android:id="@+id/emptyListView"
android:visibility="gone"/>
The ListView
works fine when there is data but the TextView
does not show up when it is empty. What am I doing wrong here?
Upvotes: 1
Views: 506
Reputation: 2264
I'd verify that the findViewById() returns non-null.
Try .findViewById() on the fragment's root view.
Upvotes: 3