Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/225.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/arduino/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android中FragmentTabHost中的TabContent_Android_Android Fragments_Fragment - Fatal编程技术网

Android中FragmentTabHost中的TabContent

Android中FragmentTabHost中的TabContent,android,android-fragments,fragment,Android,Android Fragments,Fragment,我是安卓的noob。我已经设置了FragmentTabHost现在我有一个问题,有一个名为“tabcontent”的视图组FragmeLayout。这里有什么用 <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <FrameLayout an

我是安卓的noob。我已经设置了
FragmentTabHost
现在我有一个问题,有一个名为“tabcontent”的视图组
FragmeLayout
。这里有什么用

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">


    <FrameLayout
        android:id="@android:id/tabcontent"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_weight="0" />

    <FrameLayout
        android:id="@+id/realtabcontent"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"/>

    <TabWidget
        android:id="@android:id/tabs"

        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="0"
        android:orientation="horizontal" />
</LinearLayout>



在TabContet中定义每个选项卡的根元素。 有一个示例使用滚动视图和tabcontent中两个选项卡的相对布局。 我建议您使用Tabhost作为tabwidget的父对象

 <TabHost
  android:id="@android:id/tabhost"
  android:layout_width="match_parent"
  android:layout_height="fill_parent">

      <LinearLayout
      android:layout_width="match_parent"
      android:layout_height="fill_parent"
      android:orientation="vertical" >

          <TabWidget
           android:id="@android:id/tabs"
           android:layout_width="match_parent"
           android:layout_height="wrap_content"/>

              <FrameLayout
              android:id="@android:id/tabcontent"
              android:layout_width="match_parent"
              android:layout_height="fill_parent" >

                  <ScrollView
                   android:id="@+id/tab1"
                   android:layout_width="match_parent"
                   android:layout_height="fill_parent">
                  </ScrollView>

                  <RelativeLayout
                   android:id="@+id/tab2"
                   android:layout_width="match_parent"
                   android:layout_height="fill_parent"
                   android:orientation="vertical" >
                  </RelativeLayout>

            </FrameLayout>
       </LinearLayout>
 </TabHost>

希望它能对你有所帮助。

这是你正在谈论的另一件事。您现在使用的方式已被弃用
TabHost tabs=(TabHost)findViewById(android.R.id.tabhost);
tabs.setup();


    TabHost.TabSpec spec=tabs.newTabSpec("Tittle");
    spec.setContent(R.id.tab1);
    spec.setIndicator("Tab 1");
    tabs.addTab(spec);

    spec=tabs.newTabSpec("Tittle");
    spec.setContent(R.id.tab2);
    spec.setIndicator("Tab 2");
    tabs.addTab(spec);

    tabs.setCurrentTab(0);