Android中FragmentTabHost中的TabContent
我是安卓的noob。我已经设置了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
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);