Reputation: 187
I'm using a ListView, and it is not working properly. Please see my code.
<LinearLayout
android:id="@+id/playerlist"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ListView
android:id="@+id/plist"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<TextView
android:id="@id/android:empty"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="NO DATA" />
</LinearLayout>
Well, It works well if the list is empty.
But as the list is short, You can see the 'NO DATA' below the ListView.
If you set the layout_height of the ListView to 'fill_parent', the 'NO DATA' can't appear.
Can anyone help me?
Upvotes: 2
Views: 3537
Reputation: 1438
You must apply setEmptyView(View emptyView)
to your listview.
Give your TextView an id, say emptyView
;
TextView emptyView = (TextView)findViewById(R.id.emptyView);
yourListView.setEmptyView(emptyView);
should do the trick.
Hope this helps
Upvotes: 14