こんにちは、2つのレイアウトを使用しています。1つはメインレイアウトファイルの「include」を介して埋め込まれています。メインxmlのアクティビティ内に埋め込まれたものにTextViewを設定したいと思います。これが私がこれまでに思いついたものです......
メインxml:date_list_layout.xml
<RelativeLayout android:id="@+id/RelativeLayout01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@drawable/bgoption">
<include layout="@layout/cur"
android:layout_height="wrap_content"
android:layout_width="wrap_content" />
</RelativeLayout>
埋め込まれたxml:cur.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/currency"
android:textSize="14px"
android:paddingLeft="10dp"
android:textColor="#d17375"
></TextView>
</LinearLayout>
次に、私のアクティビティコードはコンテンツをメインのxmlに設定しますが、埋め込まれたものを膨らませてテキストを次のように設定しようとします......
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.date_list_layout);
View v = LayoutInflater.from(getBaseContext()).inflate(R.layout.cur,
null);
TextView currency = (TextView) v.findViewById(R.id.currency);
currency.setText("test");
}
エラーは発生しませんが、TextViewは空のままです。私が間違っていることのアイデア
ありがとうA