0

タブホスト内のビューにアクセスできません。myTitle レイアウトと myTitleText にアクセスし、それらの属性をプログラムで変更したいと考えています。

findviewbyid と view.findviewbyid を使用しようとしましたが、null になります。インフレータを試しましたが、属性は変わりません。

助けてください

<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <LinearLayout
        android:id="@+id/layout_myTitle"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="center">

        <TextView
            android:id="@+id/title_myTitleText"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="TITLE" />
    </LinearLayout>

    <TabWidget
        android:id="@android:id/tabs"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" />

    <FrameLayout
        android:id="@android:id/tabcontent"
        android:layout_width="fill_parent"
        android:layout_height="0dip" android:layout_weight="1.0"/>
</LinearLayout>

</TabHost>
4

2 に答える 2

-1

tabHost を使用して実行

TextView tv = (TextView) tabHost.findViewById(R.id.title_myTitleText);
于 2013-04-03T11:05:57.083 に答える