开发者

Android TabHost is there a way to get TabView by ID

开发者 https://www.devze.com 2023-01-29 13:52 出处:网络
I\'m making some an advanced TabActivity but I need to get e开发者_JAVA技巧very TabView thats in the TabHost. With tabHost.getCurrentTabView() I can get the current TabView but is there a way to get a

I'm making some an advanced TabActivity but I need to get e开发者_JAVA技巧very TabView thats in the TabHost. With tabHost.getCurrentTabView() I can get the current TabView but is there a way to get a TabView by its ID?


I managed to make a workaround by doing a for loop in the onCreate() method where I go to every tab and put all the View objects in an Array.

  private View[] tabs;

  for(int i = 0; i < getTabWidget().getTabCount(); i++)
    {
        tabHost.setCurrentTab(i);
        tabs[i] = tabHost.getCurrentTabView();
    }


There is no TabView in Android.

To find the contents of a tab via its ID, call findViewById() on the TabHost.

0

精彩评论

暂无评论...
验证码 换一张
取 消