【问题标题】:Android TabHost is there a way to get TabView by IDAndroid TabHost 有没有办法通过 ID 获取 TabView
【发布时间】:2010-12-09 21:39:30
【问题描述】:

我正在制作一些高级TabActivity,但我需要获取TabHost 中的每个TabView。使用tabHost.getCurrentTabView(),我可以获得当前的TabView,但有没有办法通过其ID 获得TabView


我设法通过在 onCreate() 方法中执行 for 循环来解决问题,在该方法中,我转到每个选项卡并将所有 View 对象放入一个数组中。

  private View[] tabs;

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

【问题讨论】:

    标签: android android-tabhost tabactivity


    【解决方案1】:

    Android 中没有TabView

    要通过其 ID 查找选项卡的内容,请在 TabHost 上调用 findViewById()

    【讨论】:

      猜你喜欢
      • 2018-09-21
      • 1970-01-01
      • 2021-12-10
      • 2015-02-09
      • 2022-01-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-10
      相关资源
      最近更新 更多