启用/禁用选项卡中的动作条 [英] Enable/Disable Tab in ActionBar

查看:108
本文介绍了启用/禁用选项卡中的动作条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是可能的使能/禁用ActionBar的标签? 随着TabHost这不是一个问题。我做的:

It's possible to enable/disable Tabs in ActionBar? With TabHost this is not a problem.. I do:

tabHost.getTabWidget().getChildAt(3).setVisibility(true);

和所有的工作..但如果​​我想要做同样的事情标签的动作条? 在标签类是不存在的 setEnable();

and all works.. but if i want to do the same thing with Tabs in ActionBar?? In Tab class don't exist setEnable();

ActionBar bar = getActionBar();
Tab tab =  bar.newTab();
tab.setText("Test");
tab.setEnable(false); /*DON'T EXIST!!*/

我该怎么办??

How can I do??

推荐答案

您可以使用<一个href="http://developer.android.com/reference/android/app/ActionBar.html#removeTab%28android.app.ActionBar.Tab%29"><$c$c>removeTab( ActionBar.Tab标签) -method的动作条

bar.removeTab( tab );

然后用<一个href="http://developer.android.com/reference/android/app/ActionBar.html#addTab%28android.app.ActionBar.Tab,%20int%29"><$c$c>addTab( ActionBar.Tab标签,INT位置) 把它放回,只要你保存设置页您删除的位置:

And then use the addTab( ActionBar.Tab tab, int position ) to put it back in, provided that you save the position of the Tab you removed:

bar.addTab( tab, savedTabPosition );

这篇关于启用/禁用选项卡中的动作条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆