Android TabHost有一种通过ID获取TabView的方法 [英] Android TabHost is there a way to get TabView by ID

查看:156
本文介绍了Android TabHost有一种通过ID获取TabView的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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?

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

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();
    }

推荐答案

Android中没有TabView.

There is no TabView in Android.

要通过标签的ID查找标签的内容,请在TabHost上调用findViewById().

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

这篇关于Android TabHost有一种通过ID获取TabView的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆