如何暂时删除 TabHost 的 Tabwidget?
我正在开发一个使用 TabHost 的应用程序。在我的 TabHost 中,有四个选项卡。每个选项卡都有自己的 ActivityGroup。现在,我想要的是,在选项卡下的 ActivityGroup 内的 Acitivty 中,我想暂时删除 Tabwidget,以便框架布局在设备的整个屏幕上可见。然后,当该 Activity 切换到另一个 Activity 时,Tabwidget 将重新出现在屏幕上。所以第一个问题是,我可以这样做吗?如果那样的话,我该怎么办?如果不可能,那么是否可以在 Tabwidget 选项卡下的正常活动和 ActivityGroup 内的活动之间切换?
I am developing an app where i used TabHost. Inside my TabHost, there are four tabs. Each tab has its own ActivityGroup. Now, what i want is, in a Acitivty inside one of my ActivityGroup under a tab, i want to remove the Tabwidget temporarily so that the frameLayout will be visible through entire screen of the device. Then, when the activity switch to another activity, the Tabwidget will re-appear on the screen. So the first question is, can i do this? If then, how can i do that? If not possible, then is it possible to switch between a normal activity and an activity inside ActivityGroup under a tab of Tabwidget?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
StartActivity()
也在ActivityGroup
内部工作。因此 Activity 将在全屏中启动,并且
finish();
将发送回ActivityGroup()
。StartActivity()
works insideActivityGroup
also .so activity will start in complete screen and
finish();
will send back toActivityGroup()
.对于底部的选项卡:
For tab at the bottom:
由于
TabWiget
是View
的子类,您应该能够使用setVisibility()
隐藏/重新显示它。您需要对 TabWidget 的引用 - 该引用需要在哪里,取决于哪个类将处理隐藏/显示。在下面的示例中,我假设您将功能放入
TabActivity
中 - 因此我们添加两个方法和对TabWidget
的引用:然后在
Activity< /code> 需要隐藏选项卡,您需要执行以下操作:
要重新显示选项卡,执行相同的操作,但改为调用
((MyTabActivity) Activity).showTabs();
。Since
TabWiget
is a subclass ofView
you should be able to hide/reshow it usingsetVisibility()
.You would need a reference to your TabWidget - where this reference needs to be, depends on what class will handle hide/show. In my example below I will assume you put the functionality in your
TabActivity
- so there we add two methods and a reference to theTabWidget
:Then in the
Activity
that needs to hide the tabs you will need to do something like:And to reshow the tabs, the same thing but calling
((MyTabActivity) activity).showTabs();
instead.