如何在布局中配置操作栏?
我现在有一个工作选项卡式界面,但选项卡是在活动类中声明的。我想将这些声明移至 XML 布局文件。不幸的是,我找不到任何例子。这怎么能做到呢?
I have a working tabbed interface right now, but the tabs are declared in activity class. I want to move those declarations to an XML layout file. Unfortunately, I haven't been able to find any examples. How can this be done?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为您不能在 XML 文件中添加选项卡,只能添加 TabWidget。 TabSpec 必须以编程方式创建并添加到 TabHost
I dont think you can add Tabs in the XML file, only TabWidget can be added. TabSpecs have to be created programmatically and added to the TabHost
你看过这个教程吗?它特别提到它展示了如何在每个选项卡中显示活动。
http://developer.android.com/resources/tutorials/views/hello -tabwidget.html
编辑 - 抱歉,我注意到 XML 中只有 TabWidget,其他选项卡是在 onCreate() 方法中声明的,因此这不能回答您的问题。
Have you seen this tutorial? It specifically mentions that it shows how to display an Activity in each tab.
http://developer.android.com/resources/tutorials/views/hello-tabwidget.html
EDIT - My apologies, I notice that there is only the TabWidget in the XML and the other tabs are declared in the onCreate() method, so this doesn't answer your question.