gpt4 book ai didi

android - 如何在我们的android应用程序的每个页面上添加tabhost控件?

转载 作者:行者123 更新时间:2023-11-30 04:44:35 25 4
gpt4 key购买 nike

我想在android应用程序的每个页面上显示和处理tabhost控件的事件,而不是一次又一次地创建它,因为在asp.net中我们有masterpage概念,我们可以在上面放置我们常用的控件,android中有什么,这样我就可以将 tabcontrol 放在那里。

最佳答案

您应该使用 TabActivity 扩展您的 Activity 并使用 TabHost 和 TabSpecxml 的一个示例是

  <?xml version="1.0" encoding="utf-8"?>
<TabHost android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost">
<LinearLayout android:id="@+id/LinearLayout01"
android:orientation="vertical"
android:layout_height="fill_parent"
android:layout_width="fill_parent">
<TabWidget android:id="@android:id/tabs"
android:layout_height="wrap_content"
android:layout_width="fill_parent">
</TabWidget>
<FrameLayout android:id="@android:id/tabcontent"
android:layout_height="fill_parent"
android:layout_width="fill_parent">
</FrameLayout>
</LinearLayout>

</TabHost>

关于android - 如何在我们的android应用程序的每个页面上添加tabhost控件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5297987/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com