gpt4 book ai didi

android - 想要使整个 Tabhost 消失或不可见 onclick 特定选项卡

转载 作者:太空狗 更新时间:2023-10-29 13:38:21 25 4
gpt4 key购买 nike

说,我的 TabActivity 中有 2 个 tabs,点击其中一个 tabs,我进入了我的 Activity 调用了 FirstTab。当我在这个特定的类中时,我不希望我的 TabHost 可见。

也就是说,每当我单击选项卡时,我都希望我的 TabHost 消失。

我该怎么做?

代码 fragment :

TabSpec firstTabSpec = tabHost.newTabSpec("tid1");  
firstTabSpec.setIndicator("", getResources().getDrawable(R.drawable.icon));
firstTabSpec.setContent(new Intent(this,FirstTab.class));
tabHost.addTab(firstTabSpec);

编辑:我的 Xml:

<TabHost android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@android:id/tabhost">
<LinearLayout android:id="@+id/LinearLayout01"
android:orientation="vertical"
android:layout_height="fill_parent"
android:layout_width="fill_parent">
<TabWidget android:id="@android:id/tabs"
android:background="@drawable/bar_green"
android:layout_height="wrap_content"
android:layout_width="fill_parent"></TabWidget>
<FrameLayout android:id="@android:id/tabcontent"
android:layout_height="fill_parent"
android:layout_width="fill_parent"></FrameLayout>
</LinearLayout>
</TabHost>

我有一个简单的 FirstTab Activity,它在单击我的 tab 时显示在 TabHost 下,我想将其转换为不包含 TabHost 的类。

最佳答案

您可以尝试将 TabHost 的可见性设置为“View.GONE”

getTabHost().setOnTabChangedListener(new OnTabChangeListener() {
public void onTabChanged(String tabId) {
if (tabId=="firstTabId")
getTabHost().setVisibility(View.GONE);
}
});

但是您确定要这样做吗?用户如何返回第二个标签?

关于android - 想要使整个 Tabhost 消失或不可见 onclick 特定选项卡,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8443423/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com