[英]TabHost - how to change tab text in XML
I know the solution on how to change it programically however I would like to set the text in XML. 我知道如何以编程方式更改它的解决方案,但我想用XML设置文本。 How do you do that?
你是怎样做的? I have looked here: http://developer.android.com/reference/android/widget/TabHost.html but found no solution.
我看过这里: http : //developer.android.com/reference/android/widget/TabHost.html但没有找到解决方案。
How about .... 怎么样 ....
<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>
This way it'll look as follows: 这样看起来如下:
Check out the complete tab sample here . 在这里查看完整的标签示例。
Hope this helps .... Cheers! 希望这会有所帮助....干杯!
You can always go into the @+id/tab1 and change it to whatever you want the tab to be called. 您可以随时进入@ + id / tab1并将其更改为您希望调用选项卡的任何内容。 So if you wanted it to be called "About" just change it to @+id/About in the linear layout for the specific tab.
因此,如果您希望将其称为“关于”,只需将其更改为特定选项卡的线性布局中的@ + id / About。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.