Why don't you use ListView
's emptyView option.
Here is a nice post about showing empty view while your adapter is empty. It'll be automatically shown when your Adapter's source is empty.
Android – ListView => setEmptyView()
You don't need to check whether you data source (ArrayList
) is empty, android framework will handle all the hiding and showing implementation.
Make sure to call setEmptyView()
before you call setAdapter()
on the ListView
.