显示[否项目"在ListView的消息消息、项目、QUOT、ListView

2023-09-12 11:04:34 作者:手持情刃战情场.

我已经创造了一些composie的UI在我的Andr​​oid应用程序,有一些的ListView控件-among一个视图中其他控制 - 。正因为如此,我曾用活动作为我活动的基类。

I've created some composie UIs in my android apps and there are some ListView controls -among other controls- inside a view. Because of this, I have used "Activity" as my activity base class.

现在我需要显示一个简单的信息,如无项目时,绑定到我的适配器ListView控件是空的。我知道这是可能使用ListActivity的时候,但我不知道什么是最好的办法了吗?

Now I need to display a simple message like "No Item" when the ListView that is bound to my adapter is empty. I know this is possible when using ListActivity but I'm not sure what's the best approach for this?

推荐答案

您正在寻找一个ListActivity的空观点:

You're looking for the empty view of a ListActivity:

http://developer.android.com/reference/android/app/ListActivity.html

如果您正在使用ListView控件,您可以使用的方法setEmptyView():

If you're using ListView you can use the method setEmptyView():

http://developer.android.com/reference/android/widget/AdapterView.html#setEmptyView(android.view.View)