

Create an xml for displaying items (when the list is not empty), and name it “list_item”. This is how “my_activity” xml should look like: ģ. The message won’t be displayed if you use another name. Important: The TextView must have as id the following name: “ emptyElement”. This will be used to display the empty message. And right below the ListView, you will have to add a TextView. Now, in the just created xml “my_activity”, you will have to set the ListView. Create an xml which will hold the ListView and name it “my_activity” and an activity called “MyActivity”.Ģ. And inside the activity, set the setEmptyView() property to the ListViewġ.Set the TextView’s id as “emptyElement”.In the xml where the ListView is declared, create a TextView (the TextView can be inside a LinearLayout if you want) right below the ListView.When you want to show a message to the user when the ListView is empty, you have to keep in mind the following 3 steps:

When I first needed to set a message on a ListView that was empty, I tried different methods, but none of them worked, except the one that I will describe in this tutorial.
