I want to reveal a Toast when my listview is empty, I tried this but it doesn't work, I don't understand why:
if (listView == null) {
Toast.makeText(this, "No slots selected",
Toast.LENGTH_LONG).show();
}
I know how Toast work, but my problem is to detect when a listview is empty.
Could anyone help me plz ?
You need to check the list that attached to your ListView (by the adapter).
When a List is created you can't check by == null
because the variable is already created.
Instead checking the list size, something like this:
adapter.getCount() == 0