gpt4 book ai didi

android防止第一个选项卡上的自动启动 Activity

转载 作者:行者123 更新时间:2023-11-29 21:42:38 26 4
gpt4 key购买 nike

我的 android 应用程序有一个带有 5 个选项卡的 tabhost。问题是当我在第一个选项卡上使用 setCurrentTab(2).Android 启动 Activity 然后它在第三个选项卡上启动 Activity 。我发现当我使用 TabHost 类的方法 addTab 时,它也会在第一个选项卡中启动 Activity 。

    if (mCurrentTab == -1) {
setCurrentTab(0);
}

我在 stackoverflow 中阅读我的线程,如:https://stackoverflow.com/questions/9978231/android-when-i-put-setcurrenttab-for-tabhost-it-loads-the-first-added-tab-ac

因为我的客户要求,我无法重新排序选项卡。当 TabActivity 启动时,我只想在第三个选项卡中启动 Activity ,我该怎么做?

最佳答案

如果你想阻止加载你的 fragment ,那么把你的放在 onVisible 中。使用此类 UserVisibleHintFragment

它将帮助您防止提前加载。

关于android防止第一个选项卡上的自动启动 Activity ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16682735/

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