title: Null pointer Exception at ActionBar
body: <p>I am getting this Error at runtime.</p>
  
  <blockquote>
    <p>java.lang.RuntimeException: Unable to start activity ComponentInfo
    android.util.AndroidRuntimeException: requestFeature() must be called
    before adding content</p>
  </blockquote>
  
  <p><strong>StackTrace:</strong></p>
  
  <pre><code>01-22 04:55:59.728: E/AndroidRuntime(2443): FATAL EXCEPTION: main
  01-22 04:55:59.728: E/AndroidRuntime(2443): Process: com.qrme.quranmadeeasy, PID: 2443
  01-22 04:55:59.728: E/AndroidRuntime(2443): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.qrme.quranmadeeasy/com.qrme.quranmadeeasy.ChapterActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.app.ActionBar.setBackgroundDrawable(android.graphics.drawable.Drawable)' on a null object reference
  01-22 04:55:59.728: E/AndroidRuntime(2443):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
  01-22 04:55:59.728: E/AndroidRuntime(2443):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
  01-22 04:55:59.728: E/AndroidRuntime(2443):     at android.app.ActivityThread.access$800(ActivityThread.java:144)
  01-22 04:55:59.728: E/AndroidRuntime(2443):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
  01-22 04:55:59.728: E/AndroidRuntime(2443):     at android.os.Handler.dispatchMessage(Handler.java:102)
  01-22 04:55:59.728: E/AndroidRuntime(2443):     at android.os.Looper.loop(Looper.java:135)
  01-22 04:55:59.728: E/AndroidRuntime(2443):     at android.app.ActivityThread.main(ActivityThread.java:5221)
  01-22 04:55:59.728: E/AndroidRuntime(2443):     at java.lang.reflect.Method.invoke(Native Method)
  01-22 04:55:59.728: E/AndroidRuntime(2443):     at java.lang.reflect.Method.invoke(Method.java:372)
  01-22 04:55:59.728: E/AndroidRuntime(2443):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
  01-22 04:55:59.728: E/AndroidRuntime(2443):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
  01-22 04:55:59.728: E/AndroidRuntime(2443): Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.app.ActionBar.setBackgroundDrawable(android.graphics.drawable.Drawable)' on a null object reference
  01-22 04:55:59.728: E/AndroidRuntime(2443):     at com.qrme.quranmadeeasy.ChapterActivity.ActionBar(ChapterActivity.java:212)
  01-22 04:55:59.728: E/AndroidRuntime(2443):     at com.qrme.quranmadeeasy.ChapterActivity.initialize(ChapterActivity.java:112)
  01-22 04:55:59.728: E/AndroidRuntime(2443):     at com.qrme.quranmadeeasy.ChapterActivity.onCreate(ChapterActivity.java:68)
  01-22 04:55:59.728: E/AndroidRuntime(2443):     at android.app.Activity.performCreate(Activity.java:5933)
  01-22 04:55:59.728: E/AndroidRuntime(2443):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
  01-22 04:55:59.728: E/AndroidRuntime(2443):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
  01-22 04:55:59.728: E/AndroidRuntime(2443):     ... 10 more
  </code></pre>
  
  <p><strong>Edited:</strong></p>
  
  <p><strong>ChapterActivity.java:</strong></p>
  
  <pre><code>import android.support.v7.app.ActionBarActivity;
  
  public class ChapterActivity extends ActionBarActivity implements OnItemClickListener {
  
  @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
      //  requestWindowFeature(Window.FEATURE_ACTION_BAR);
          setContentView(R.layout.activity_chapter);
  
          initialize();  ---&gt;68th line
  }
  private void initialize() {
  
      listChapter.setDivider(new ColorDrawable(Color
                  .parseColor(separator_grey)));
          listChapter.setDividerHeight(2);
      ............
  
      ActionBar();  --&gt;112th line
      }
  
  public void ActionBar() {
          ActionBar actionBar = getActionBar();
          actionBar.setBackgroundDrawable(new ColorDrawable(Color   ---&gt;212th line
                  .parseColor(white)));  
          actionBar.setDisplayShowHomeEnabled(false);
          actionBar.setDisplayShowTitleEnabled(false);
          LayoutInflater mInflater = LayoutInflater.from(this);
  
           .........
          actionBar.setCustomView(mCustomView);
          actionBar.setDisplayShowCustomEnabled(true);
      } 
  }
  </code></pre>
  
  <p>styles.xml:</p>
  
  <pre><code>&lt;resources&gt;
  
      &lt;style name="AppBaseTheme" parent="@style/Theme.AppCompat"&gt;&lt;/style&gt;
  
      &lt;!-- Application theme. --&gt;
      &lt;style name="AppTheme" parent="AppBaseTheme"&gt;
          &lt;!-- All customizations that are NOT specific to a particular API-level can go here. --&gt;
      &lt;/style&gt;
  &lt;/resources&gt;
  </code></pre>
  
  <p><strong>Manifest:</strong></p>
  
  <pre><code>  &lt;application
          android:name="com.qrme.quranmadeeasy.Application"
          android:allowBackup="true"
          android:icon="@drawable/ic_launcher"
          android:label="@string/app_name"
          android:theme="@style/AppTheme" &gt;
          &lt;activity
              android:name=".MainActivity"
              android:label="@string/app_name"
              android:screenOrientation="portrait"            
                 &gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;
  
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
       ........
      &lt;application&gt;
  </code></pre>
  
  <p>I didn't know how to solve this.Anyone can help me with this.Thank you.</p>