Android setting custom title bar error
<p>I am creating a simple Android app where I want to add a custom title bar to it. However I stuck on a problem when I creating the custom title bar.</p>

<p>Here is my OnCreate method in GetPhoto Activity class:</p>

<pre><code>protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        boolean titled = requestWindowFeature(Window.FEATURE_CUSTOM_TITLE
        setContentView(R.layout.getphoto);
        getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.title_complex);

        initialize();
    }
</code></pre>

<p>And My title_complex.xml  (for define the custom title):</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="35dip"
    android:gravity="center_vertical"
    android:orientation="horizontal" &gt;

    &lt;Imageview
        android:src="@drawable/header"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" /&gt;

    &lt;TextView
        android:text="Hello world!"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="#7cfc00" /&gt;

&lt;/LinearLayout&gt;
</code></pre>

<p>When I put getWindow().setFeatureInt() after setContentView(), I got errors like this:</p>

<pre><code>FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.featureselection/com.example.featureselection.GetPhoto}: android.view.InflateException: Binary XML file line #16: Error inflating class Imageview
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1968)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1993)
at android.app.ActivityThread.access$600(ActivityThread.java:127)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1159)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
...
</code></pre>

<p>featureselection is the app name and GetPhoto is the class which contains the OnCreate method showed above.
I have no idea why it gives errors. I saw other people also write the code like this and it works fine.</p>

<p>And another thing is if I put getWindow().setFeatureInt() before setContentView(), when I run my app, it does not give errors, but nothing is shown on the custom title bar, whereas I expect an image and "hello world" to be shown on the custom title bar.</p>

<p>FYI:
I also have this customer_style.xml in the res/values folder:</p>

<pre><code>&lt;resources&gt;
    &lt;style name="CustomWindowTitleBackground"&gt;
        &lt;item name="android:background"&gt;#008000&lt;/item&gt;
    &lt;/style&gt;

    &lt;style name="CustomTheme" parent="android:Theme"&gt;
        &lt;item name="android:windowTitleSize"&gt;35dip&lt;/item&gt;
        &lt;item name="android:windowTitleBackgroundStyle"&gt;@style/CustomWindowTitleBackground&lt;/item&gt;
    &lt;/style&gt;
&lt;/resources&gt;
</code></pre>

<p>to set the styles.</p>

<p>Does any one know what is the problem and how to solve it? Any seggestions or solutions will be appricated.</p>
