Ok i will try to be as detailed as i can here. I have an app with multiple activities in it. Some of the activities I want to have a custom title bar on with an Image, then text, then image button navigating back to the home(aka main activity). Most of the pages i want the custom title bar on are list view pages. I have successively been able to load the custom title bar but it doesn't load any text field or images just the title bar with nothing in it. here is the code that i've used.
window_title.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="50dip"
android:gravity="center_vertical"
android:paddingLeft="5dip"
android:background="#660000">
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/icon72" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.39"
android:gravity="right|center_vertical"
android:paddingRight="5dip" >
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp"
android:text="@string/app_name"
android:textColor="#FFFFFF"
android:paddingRight="5dip" />
<ImageButton
android:id="@+id/imageButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#660000"
android:src="@drawable/home" />
<ImageView
android:id="@+id/home"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
</LinearLayout>
custom_style.xml
<resources>
<style name="CustomWindowTitleBackground">
<item name="android:background">#660000</item>
</style>
<style name="CustomTheme" parent="android:Theme">
<item name="android:windowTitleSize">50dip</item>
<item name="android:windowTitleBackgroundStyle">@style/CustomWindowTitleBackground</item>
</style>
Classes.Java
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
public class Classes extends ListActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.window_title);
setListAdapter( new ArrayAdapter<String>(this, R.layout.ministries, list));
ListView list = getListView();
list.setTextFilterEnabled(true);
list.setOnItemClickListener(new OnItemClickListener(){
I'm not sure what i'm doing wrong or where i need to make changes but I would like to be able to have this custom title bar on some of the activities and load the name of that activity in the title bar. I've looked at several tutorials and these two have helped but i'm kinda stuck a bit. http://staticallytyped.wordpress.com/2011/03/18/android-dynamic-and-custom-title-bars/ and this one has helped the most and what i basicly followed http://www.londatiga.net/it/how-to-create-custom-window-title-in-android/
Thank you for any help you can give. I would have posted pics but haven't gotten that far on here yet so thank you again for any help
edit
the top image is what i want the title bar to look like and the bottom is what it looks like in app
YOu can use include tag of android to add your window_title.xml....
Refer : android include tag - invalid layout reference http://developer.android.com/resources/articles/layout-tricks-merge.html