Android TabHost is there a way to get TabView by ID

主宰稳场 提交于 2020-01-02 10:35:33

问题


I'm making some an advanced TabActivity but I need to get every 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();
    }

回答1:


There is no TabView in Android.

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



来源:https://stackoverflow.com/questions/4403387/android-tabhost-is-there-a-way-to-get-tabview-by-id

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