私は、すべてのアクティビティの上部にヘッダーを持つアプリを作成しています。これまでのところ、私はそれを行ってきました:
すべてのページの header.xml を作成します。しかし、もっと効率的な方法が必要だと思います。
定数 header.xml を使用して、onCreate メソッドのテキストの値を変更できますか?
これは私がこれまでやってきたことです:
アクティビティを選択し、
レイアウト chooseact.xml で
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/white">
<include layout="@layout/selectheader" />
<include layout="@layout/redcell" />
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</TableLayout>
その中で header.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="match_parent"
android:layout_height="60dp"
android:src="@drawable/headerrect" />
<TextView
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:gravity="center"
android:text="@string/leagues"
android:textColor="@color/white"
android:textSize="25dp"
android:textStyle="bold"/>
</RelativeLayout>