Android 在一个视图中创建多个tabhost图元

Android 在一个视图中创建多个tabhost图元,android,android-tabhost,Android,Android Tabhost,我试图在一个视图中创建多个tabhosts。在本例中,我使用的代码示例来自iosched应用程序和“workspace”视图,该视图允许用户向左/向右滑动以在视图之间滑动 每个滑动视图将包含一个tabhost 我遇到的问题是,当我填充第二个、第三个etc选项卡主机时,所有内容都出现在第一个选项卡主机上,而不是正确的选项卡主机上 我有一个对象列表,列表中的每个对象都有一个单独的tabhost: Outer loop over each xxx to build a tabhost for

我试图在一个视图中创建多个tabhosts。在本例中,我使用的代码示例来自iosched应用程序和“workspace”视图,该视图允许用户向左/向右滑动以在视图之间滑动

每个滑动视图将包含一个tabhost

我遇到的问题是,当我填充第二个、第三个etc选项卡主机时,所有内容都出现在第一个选项卡主机上,而不是正确的选项卡主机上

我有一个对象列表,列表中的每个对象都有一个单独的tabhost:

    Outer loop over each xxx to build a tabhost for each xxx

    // Setup views
    ctlr.mRootView = (ViewGroup) inflater.inflate(R.layout.controllers_list_content_tabbed, null);

    ctlr.scrollView = (ObservableScrollView) ctlr.mRootView.findViewById(R.id.controllers_scroll);
    ctlr.scrollView.setOnScrollListener(this);

    ctlr.mTabHost = (TabHost) ctlr.mRootView.findViewById(android.R.id.tabhost);
    ctlr.mTabWidget = (TabWidget) ctlr.mRootView.findViewById(android.R.id.tabs);
    ctlr.mTabHost.setup();
    ctlr.mTabRealContentView = ctlr.mRootView.findViewById(R.id.realtabcontent);
    int mTabReakContentViewId = ctlr.mTabRealContentView.getId();
    ctlr.mTabManager = new TabManager(this, ctlr.mTabHost, mTabReakContentViewId);
    .
    .
    . I loop several tabs like the snippet below and I expect each of these tabs on each tabhost
    .
    // Supply controller uri as an argument.
    Bundle args = new Bundle();
    args.putInt("controllerId", ctlr.mControllerId);

    String tagSpec = TAG_PROBES + "_" + ctlr.mControllerId.toString();
    ctlr.mTabManager.addTab(ctlr.mTabHost.newTabSpec(tagSpec)
                                            .setIndicator(buildIndicator(ctlr, R.string.db_maint_probes)),
                            DbMaintProbesFragment.class, 
                            args);

    .
    .
    .
    mWorkspace.addView(ctlr.mRootView);
    mCtlrs.add(ctlr);  <<-- this is the linked list of all the items added to the workspace
每个xxx上的外部循环,为每个xxx构建一个tabhost
//设置视图
ctlr.mRootView=(视图组)充气器。充气(R.layout.controllers\u list\u content\u tabbed,null);
ctlr.scrollView=(ObservableScrollView)ctlr.mRootView.findViewById(R.id.controllers\u scroll);
Ctrr.scrollView.setOnScrollListener(这个);
ctlr.mTabHost=(TabHost)ctl.mRootView.findViewById(android.R.id.TabHost);
ctlr.mTabWidget=(TabWidget)ctlr.mRootView.findViewById(android.R.id.tabs);
ctlr.mTabHost.setup();
ctlr.mTabRealContentView=ctlr.mRootView.findViewById(R.id.realtabcontent);
int mTabReakContentViewId=ctll.mTabRealContentView.getId();
ctlr.mTabManager=new TabManager(这个,ctlr.mTabHost,mTabReakContentViewId);
.
.
. 我循环几个选项卡,如下面的代码片段,我希望每个选项卡上都有这些选项卡
.
//提供控制器uri作为参数。
Bundle args=新Bundle();
参数putInt(“controllerId”,ctlr.mControllerId);
字符串tagSpec=TAG_PROBES+“”+ctlr.mControllerId.toString();
ctlr.mTabManager.addTab(ctlr.mTabHost.newTabSpec(tagSpec)
.setIndicator(buildIndicator(ctlr,R.string.db_maint_探测)),
DbMaintProbesFragment.class,
args);
.
.
.
mWorkspace.addView(ctlr.mRootView);

mCtlrs.add(ctlr) 什么是TabManager?我在Android开发文档中找不到它

从我所看到的,您只创建了一个TabHost和一个TabManager,并向其中添加了选项卡。你肯定想要不止一个


我会使用一个ViewFlipper并向其添加许多线性布局。然后,我会将选项卡主体添加到每个线性布局中。这将创建多个“屏幕”,在向左/向右滑动时可以连接起来查看,每个“屏幕”包含自己的选项卡集。

对不起,TabManager是一个帮助类,在Google示例代码中记录,它帮助管理选项卡上的片段。上面的代码片段在循环中为我要创建的每个tabhost执行一次。