gpt4 book ai didi

android - TabHost - 如何更改 XML 中的选项卡文本

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:33:20 25 4
gpt4 key购买 nike

我知道如何以编程方式更改它的解决方案,但我想在 XML 中设置文本。你是怎样做的?我看过这里:http://developer.android.com/reference/android/widget/TabHost.html但没有找到解决方案。

最佳答案

怎么样....

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >

<TabHost
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content">

<TextView
android:tag="tab0"
android:text="Tab 1"
android:background="@android:drawable/btn_star_big_on"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
/>
<TextView
android:tag="tab1"
android:text="Tab 2"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
/>
<TextView
android:tag="tab2"
android:text="Tab 3"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
/>

</TabWidget>

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

<TextView
android:text="Hallo1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
<TextView
android:text="Hallo2"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
<TextView
android:text="Hallo3"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />

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

</RelativeLayout>

这样它看起来如下:

TabHost

查看完整的标签样本 here .

希望这有助于....干杯!

关于android - TabHost - 如何更改 XML 中的选项卡文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17087940/

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