- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我有一个带有 ListView 和另一个 Activity 的选项卡。那是我的代码:
TabHost tabHost = getTabHost();
TabHost.TabSpec spec;
Intent intent;
intent = new Intent().setClass(this, ListNoteActivity.class);
spec = tabHost.newTabSpec("list").setIndicator(getString(R.string.list),
res.getDrawable(R.drawable.ic_tab_new)).setContent(intent);
tabHost.addTab(spec);
intent = new Intent().setClass(this, NewNoteActivity.class);
spec = tabHost.newTabSpec("view").setIndicator(getString(R.string.view),
res.getDrawable(R.drawable.ic_tab_new)).setContent(intent);
tabHost.addTab(spec);
tabHost.setCurrentTab(0);
如果选项卡 0 中的列表为空,我如何显示消息或 TextView?
最佳答案
在您的 ListActivity 中,将此布局设置为内容 View :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView android:id="@+id/android:list"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</ListView>
<TextView android:id="@android:id/empty"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="No Items!"/>
</LinearLayout>
如果 ListView 为空,ListActivity 将自动显示 TextView 。您的 Activity 代码的其余部分保持完全相同。
关于android - Tab 中空 ListView 的消息 - Android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10972792/
这个问题已经有答案了: How does a for loop work, specifically for(;;)? (6 个回答) 已关闭 7 年前。 我正在查看 java.util.Random
平台:x32 上的 .NET Framework 3.5 SP1 在代码中留下空语句(“;”本身)是否存在任何性能问题? 要标记为答案,您是否还会教一个人(我?和其他阅读本文的人)钓鱼?意思是,如何确
我找到了有关在选中时更改实际复选标记颜色的说明,但我正在尝试弄清楚如何更改框的颜色。 我把盒子放在较暗的背景上,很难看清,所以我想让它变亮。 我已经尝试了大多数其他元素在 Materialise 中观
在 Java 中,如何生成空/“nil”的实例 java.util.UUID所有 128 位都为零的对象? 00000000-0000-0000-0000-000000000000 Nil UUID
我有一个带有 ListView 和另一个 Activity 的选项卡。那是我的代码: TabHost tabHost = getTabHost(); TabHost.TabSpec spec; I
当我做计算机科学圈第14章的题时,我发现了一些奇怪的事情。 问题说:“定义一个函数 postalValidate(S),它首先检查 S 是否代表有效的邮政编码:首先,删除所有空格;余数必须采用 L#L
clearfix div 中空注释的目的是什么?我假设这是针对某种较旧的浏览器填充程序;不确定你为什么要四处乱放空评论。似乎只有一两个 CSS 规则会更容易维护。 最佳答案 如果网站使用 displa
我在 IE8 中的 z-index 有问题(其他 IS 尚未测试): 以下 JS 创建了一些 html/css: document.write(''); document.write(' '
我是一名优秀的程序员,十分优秀!