Android Tab Help. How to set 2nd tab as default when app opens?

老子叫甜甜 提交于 2019-12-01 17:23:06

Use this method to set the current tab after you added tab in tabHost

tabHost.setCurrentTab(1);  // here pass the tab index its starting from 0

use tabHost.setCurrentTab(1); in your onCreate

public override void OnResume() 
    {
        base.OnResume();
        tabHost.CurrentTab = 1; //index of the tab you want to set to default.
    }

Override the OnResume() and assign the CurrentTab property of tabHost to the index of the tab you want to.

There are some difficulties if you have fragments. The hack is to make tab selection delayed. See code in this answer.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!