作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在 Activty 中创建了一个 tabHost,每次它到达 .addTab(Spec) 时都会崩溃。我在 Activity 中创建了选项卡主机,如下所示:
peopleTabHost = new TabHost(this);
然后我使用一种方法来添加选项卡(我可以这样做,因为我在 onCreat 之外将 peopleTabHost 定义为 Final)
private void CreateNewTab(String tagName, String displayedName, Class<?> intentClass)
{
Intent intent = new Intent().setClass(this, intentClass);
TabHost.TabSpec spec = peopleTabHost.newTabSpec(tagName).setIndicator(displayedName);
spec.setContent(intent);
peopleTabHost.addTab(spec);
}
谢谢
最佳答案
我同意 sianis 的回答,但我还补充说,它可能会崩溃,因为您没有初始化(或至少没有显示)tabhost。
尝试在调用构造函数后立即运行 peopleTabHost.setup();
。
关于java - 如何在非 TabActivity 的 Activity 中创建 tabHost,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8701611/
我是一名优秀的程序员,十分优秀!