0

私はこのようなxmlを持っています:

以下のコードを含む item.xml:

<TextView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/list_item_title"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:paddingTop="15dip"
    android:paddingBottom="15dip"
    android:paddingLeft="15dip"
    android:textSize="24sp"/>

現在、アクティビティに別の setcontentView があります。このテキストビューの ID を取得して、テキストビューのフォントと色を設定しようとしています。

私はこれを試しましたが、動作しません:

View inflatedView = getLayoutInflater().inflate(R.layout.item, null);
        TextView tv = (TextView) inflatedView.findViewById(R.id.list_item_title);
        tv.setTextColor(Color.RED);
4

0 に答える 0