如何在Android标签布局中隐藏标签?

时间:2022-09-13 20:52:42

I have a tab layout containing 3 tabs. I want to add 4th tab at run time and hide this tab after some time. Please let me know how to hide a tab in Android.

我有一个包含三个选项卡的选项卡布局。我想在运行时添加第4个选项卡,一段时间后隐藏这个选项卡。请告诉我如何在Android中隐藏标签。

1 个解决方案

#1


42  

Get TabHost from resource as

从资源as获取TabHost

TabHost  tabHost = (TabHost)findViewById(android.R.id.tabhost);

Then runtime use this

然后运行时使用这个

tabHost.getTabWidget().getChildAt(3).setVisibility(View.GONE);

Supposing that you are trying to hide 4th Tab.(So 3 is used)

假设你想隐藏第4个标签。(3)

#1


42  

Get TabHost from resource as

从资源as获取TabHost

TabHost  tabHost = (TabHost)findViewById(android.R.id.tabhost);

Then runtime use this

然后运行时使用这个

tabHost.getTabWidget().getChildAt(3).setVisibility(View.GONE);

Supposing that you are trying to hide 4th Tab.(So 3 is used)

假设你想隐藏第4个标签。(3)