简体   繁体   English

Android操作栏在一个标签中将多个片段标签

[英]Android actionbar tabs multiple fragments in one tab

I am creating a tabbed application and the main activity for one of the tabs is a listing of departments. 我正在创建一个选项卡式应用程序,并且其中一个选项卡的主要活动是部门列表。 When you click on a department it starts a new activity that lists the documents in the department. 当您单击部门时,它将启动一个新活动,该活动列出了该部门中的文档。

My issue is when it shows the document listing, the tabbed view goes away. 我的问题是当它显示文档列表时,选项卡式视图消失了。 And I would like to keep the tabs on the top constantly. 我想一直保持顶部的标签。 I have attempted to extend the TabActivity to each of the activities that are started under the tab, but then the listviews create over eachother. 我试图将TabActivity扩展到在选项卡下启动的每个活动,但是列表视图在彼此之间创建。

I have also attempted to create the tabs without a tablistener starting an activity, so I can only create the listener if it is the first time the tab is called, but that is not allowed. 我还尝试了在不使用Tablistener启动活动的情况下创建选项卡,因此,只有在第一次调用选项卡时,我才能创建侦听器,但不允许这样做。

Any help would be appreciated, maybe there is some method I am completely missing? 任何帮助将不胜感激,也许我完全缺少某些方法?

Thank you! 谢谢!

And I would like to keep the tabs on the top constantly. 我想一直保持顶部的标签。

Then you should not be starting an activity when the user taps on tab. 然后,当用户点击选项卡时,您不应该开始活动。 Your tab contents should either be fragments or something else manipulated by your TabListener . 选项卡的内容应该是片段,也可以是TabListener操纵的其他TabListener The concept of activities being the contents of tabs is now deprecated (and, IMHO, was a bad idea to begin with). 现在不赞成使用活动的概念(即选项卡的内容)(恕我直言,首先是个坏主意)。

I have attempted to extend the TabActivity to each of the activities that are started under the tab, but then the listviews create over eachother. 我试图将TabActivity扩展到在选项卡下启动的每个活动,但是列表视图在彼此之间创建。

You will notice that TabActivity is deprecated, specifically for the activities-as-the-contents-of-tabs concept. 您将注意到不赞成使用TabActivity ,特别是针对“选项卡中的活动”概念。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM