显示[否项目"在ListView的消息 [英] Display "No Item" message in ListView

查看:111
本文介绍了显示[否项目"在ListView的消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创造了一些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:

<一个href="http://developer.android.com/reference/android/app/ListActivity.html">http://developer.android.com/reference/android/app/ListActivity.html

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

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

<一个href="http://developer.android.com/reference/android/widget/AdapterView.html#setEmptyView(android.view.View">http://developer.android.com/reference/android/widget/AdapterView.html#setEmptyView(android.view.View)

这篇关于显示[否项目&QUOT;在ListView的消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆