title: Custom action bar
body: <p>I created a layout for a custom action bar:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/contacts_action_bar"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  android:orientation="horizontal"
  android:background="#835CA1"
  android:padding="1dip" &gt;
  
  &lt;!-- ListRow Left side Thumbnail image --&gt;
  
  &lt;LinearLayout
      android:id="@+id/thumbnail"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_marginRight="5dip"
      android:padding="3dip"
      android:layout_centerVertical="true" &gt;
  
      &lt;ImageView
          android:id="@+id/home_image"
          android:contentDescription="@string/app_name"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:src="@drawable/cantacts_icon_action_bar" /&gt;
  &lt;/LinearLayout&gt;
  
  
  &lt;LinearLayout
      android:id="@+id/thumbnaill"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
  
      android:layout_toRightOf="@+id/thumbnail"
      android:orientation="vertical" &gt;
      &lt;TextView
          android:id="@+id/contactname"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_marginLeft="4dip"
          android:textColor="#FFFFFF"
          android:textSize="14sp"
          android:typeface="sans"
          android:text="Super Mario" /&gt;
  
      &lt;TextView
          android:id="@+id/onlineoroffline"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_marginLeft="4dip"
          android:textColor="#E876AF"
          android:textSize="12sp"
          android:typeface="sans"
          android:text="Online" /&gt;
  &lt;/LinearLayout&gt;
  
  &lt;LinearLayout
      android:id="@+id/thumbnail_edit"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentRight="true"
      android:layout_marginRight="5dip"
      android:padding="3dip"
      android:layout_centerVertical="true" &gt;
  
      &lt;ImageView
          android:id="@+id/edit_image"
          android:contentDescription="@string/app_name"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:src="@drawable/edit_action_bar" /&gt;
  &lt;/LinearLayout&gt;
  
  &lt;LinearLayout
      android:id="@+id/thumbnail_favorites"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_toLeftOf="@+id/thumbnail_edit"
      android:layout_marginRight="5dip"
      android:padding="3dip"
      android:layout_centerVertical="true" &gt;
  
      &lt;ImageView
          android:id="@+id/favorites_image"
          android:contentDescription="@string/app_name"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:src="@drawable/star_action_bar_unselected" /&gt;
  &lt;/LinearLayout&gt;
  
  
  &lt;/RelativeLayout&gt;  
  </code></pre>
  
  <p>which gives me the following action bar: </p>
  
  <p><img src="https://i.stack.imgur.com/9t8Ll.png" alt="enter image description here"></p>
  
  <p>Then I set the following methods in code:</p>
  
  <pre><code>ActionBar ab = getActionBar();
  ab.setDisplayShowCustomEnabled(true);
  ab.setCustomView(R.id.contacts_action_bar); // Id of the custom_action_bar
  </code></pre>
  
  <p>The application crashes, when I launch it. Is it even possible to set a custom action bar like this?</p>
  
  <p>I'm trying to do this, because I can't customize it enough programatically. </p>
  
  <p>I know, I could set the views, marked with red, with the methods:</p>
  
  <pre><code>actionBar.setIcon(R.id.homeicon);
  actionBar.setTitle("Some title");
  </code></pre>
  
  <p>and I know, I could set action buttons, as explained <a href="http://developer.android.com/guide/topics/ui/actionbar.html#ActionItems" rel="nofollow noreferrer">here</a>.</p>
  
  <p>But how would I add the online/offline label, marked with blue, in the picture below?</p>
  
  <p><img src="https://i.stack.imgur.com/U6Fly.png" alt="enter image description here"></p>
  
  <p>EDIT: Logcat output</p>
  
  <pre><code>08-24 14:16:00.257: E/AndroidRuntime(31831):    FATAL EXCEPTION: main
  08-24 14:16:00.257: E/AndroidRuntime(31831):    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.appcloned/com.example.appcloned.ContactActivity}: android.content.res.Resources$NotFoundException: Resource ID #0x7f0a0000 type #0x12 is not valid
  08-24 14:16:00.257: E/AndroidRuntime(31831):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2194)
  08-24 14:16:00.257: E/AndroidRuntime(31831):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2229)
  08-24 14:16:00.257: E/AndroidRuntime(31831):    at android.app.ActivityThread.access$600(ActivityThread.java:139)
  08-24 14:16:00.257: E/AndroidRuntime(31831):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1261)
  08-24 14:16:00.257: E/AndroidRuntime(31831):    at android.os.Handler.dispatchMessage(Handler.java:99)
  08-24 14:16:00.257: E/AndroidRuntime(31831):    at android.os.Looper.loop(Looper.java:154)
  08-24 14:16:00.257: E/AndroidRuntime(31831):    at android.app.ActivityThread.main(ActivityThread.java:4945)
  08-24 14:16:00.257: E/AndroidRuntime(31831):    at java.lang.reflect.Method.invokeNative(Native Method)
  08-24 14:16:00.257: E/AndroidRuntime(31831):    at java.lang.reflect.Method.invoke(Method.java:511)
  08-24 14:16:00.257: E/AndroidRuntime(31831):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
  08-24 14:16:00.257: E/AndroidRuntime(31831):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
  08-24 14:16:00.257: E/AndroidRuntime(31831):    at dalvik.system.NativeStart.main(Native Method)
  08-24 14:16:00.257: E/AndroidRuntime(31831):    Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f0a0000 type #0x12 is not valid
  08-24 14:16:00.257: E/AndroidRuntime(31831):    at android.content.res.Resources.loadXmlResourceParser(Resources.java:2358)
  08-24 14:16:00.257: E/AndroidRuntime(31831):    at android.content.res.Resources.getLayout(Resources.java:952)
  08-24 14:16:00.257: E/AndroidRuntime(31831):    at android.view.LayoutInflater.inflate(LayoutInflater.java:394)
  08-24 14:16:00.257: E/AndroidRuntime(31831):    at com.android.internal.app.ActionBarImpl.setCustomView(ActionBarImpl.java:260)
  08-24 14:16:00.257: E/AndroidRuntime(31831):    at com.example.appcloned.ContactActivity.onCreate(ContactActivity.java:23)
  08-24 14:16:00.257: E/AndroidRuntime(31831):    at android.app.Activity.performCreate(Activity.java:4531)
  08-24 14:16:00.257: E/AndroidRuntime(31831):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1071)
  08-24 14:16:00.257: E/AndroidRuntime(31831):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2150)
  08-24 14:16:00.257: E/AndroidRuntime(31831):    ... 11 more
  </code></pre>