I am creating an app that has headers at the top of every activity and so far the way I have been doing it:
Creating a header.xml for every page. But I think there must be a more efficient way.
Can I have a constant header.xml and then change the value of the text in my onCreate-method.
This is what I have been doing so far:
chooseActivity,
with the layout 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>
inside that a 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>