开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜