Loading a standard layout into a ListActivity
I'd like my App to show a warning message if there are no elements to load on a ListActivity; so I thought to write this on the onResume event:
if(elementsToLoad.size()==0) setContentView (alternative layout); else loadList();
but it crashes..开发者_StackOverflow.How could I fix this?
You can use an empty view. See setEmptyView(View emptyView)
method from ListView. Or you can add view to your layout with id @android:id/empty and ListView will show it for you, if list is empty.
精彩评论