如何在Android中添加TabBar

如何在Android中添加TabBar,android,Android,尊敬的所有人 我必须在我的应用程序中添加TabBar,但我不知道如何将TabBar添加到应用程序或活动中。你能帮我吗 多谢各位 Vikram Kadam您必须使用TabHost。 你可以找到一个明确的例子。阅读图图的解释,这里你只有代码。 简而言之: 您需要一个xml文件,每个选项卡都有一些布局,还需要一个活动来显示选项卡: 在xml tabs.xml中: http://schemas.android.com/apk/res/android” android:orientation=“垂直” a

尊敬的所有人 我必须在我的应用程序中添加TabBar,但我不知道如何将TabBar添加到应用程序或活动中。你能帮我吗

多谢各位
Vikram Kadam

您必须使用
TabHost
。 你可以找到一个明确的例子。阅读图图的解释,这里你只有代码。 简而言之:
您需要一个xml文件,每个选项卡都有一些布局,还需要一个活动来显示选项卡: 在xml tabs.xml中:
http://schemas.android.com/apk/res/android” android:orientation=“垂直” android:layout\u width=“fill\u parent” android:layout\u height=“fill\u parent” >


谢谢杰夫的芭蕾舞曲

你必须使用
TabHost
。 你可以找到一个明确的例子。阅读图图的解释,这里你只有代码。 简而言之:
您需要一个xml文件,每个选项卡都有一些布局,还需要一个活动来显示选项卡: 在xml tabs.xml中:
http://schemas.android.com/apk/res/android” android:orientation=“垂直” android:layout\u width=“fill\u parent” android:layout\u height=“fill\u parent” >


谢谢杰夫的芭蕾舞曲

Sephy我们能把标签栏和屏幕底部对齐吗?嗯,我不知道。。。我习惯于将其与默认显示一起使用。我认为您需要覆盖TabHost/TabWidget并更改bevahiour。这可能会很长…我们可以把标签栏和屏幕底部对齐吗?嗯,我不知道。。。我习惯于将其与默认显示一起使用。我认为您需要覆盖TabHost/TabWidget并更改bevahiour。那可能会很长。。。
<TabHost
id=”@+id/tabs”
android:layout_width=”fill_parent”
android:layout_height=”fill_parent”
>

<TabWidget
id=”@android:id/tabs”
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
/>
<FrameLayout
id=”@android:id/tabcontent”
android:layout_width=”fill_parent”
android:layout_height=”200px”
android:paddingTop=”30px”
>
<LinearLayout
id=”@+id/content1″
android:orientation=”vertical”
android:layout_width=”fill_parent”
android:layout_height=”fill_parent”
android:background=”#ff99ccff”
>
<TextView
android:layout_width=”fill_parent”
android:layout_height=”wrap_content”
android:text=”tab item uno :) ”
/>
</LinearLayout>
<LinearLayout
id=”@+id/content2″
android:orientation=”vertical”
android:layout_width=”fill_parent”
android:layout_height=”fill_parent”
android:background=”#ffffcc99″
>
<TextView
android:layout_width=”fill_parent”
android:layout_height=”wrap_content”
android:text=”tab item dos :/”
/>
<Button
android:layout_width=”fill_parent”
android:layout_height=”wrap_content”
android:text=”tabhost needs”
/>
<Button
android:layout_width=”fill_parent”
android:layout_height=”wrap_content”
android:text=”to be upgraded ;) ”
/>
</LinearLayout>
</FrameLayout>
</TabHost>
</LinearLayout>
setContentView(R.layout.tabs);

TabHost tabs = (TabHost)this.findViewById(R.id.tabs);
tabs.setup();

tabs.addTab(“one”, R.id.content1, “labelone”);
tabs.addTab(“two”, R.id.content2, “labeltwo”);