title: Reuse the Action Bar in all the activities of app
body: <p>I am a newbie to android and I was wondering if someone could guide me about how to reuse the action bar in all of my android activities. As far as I have explored, I found out that we have to make a BaseActivity class and extend it in our Activity where we want to reuse it, and also we have to make a xml layout and include it in our activity xml file. I have finished with the BaseActivity part. Now I am sort of confused in framing the xml part and including it. I know how to merge and include a layout, But in case of Action Bar, what necessary steps are to be taken. Any help would be appreciated.</p>
  
  <p>This is my BaseMenuActivity:</p>
  
  <pre><code>public class BaseMenuActivity extends Activity{
  
      ActionBar actionBar;
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          // TODO Auto-generated method stub
          super.onCreate(savedInstanceState);
          actionBar = getActionBar();
          actionBar.setDisplayHomeAsUpEnabled(true);
          actionBar.setDisplayShowCustomEnabled(true);
          actionBar.setIcon(R.drawable.ic_social_share);
          LayoutInflater inflator = (LayoutInflater) this
                  .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
          View v = inflator.inflate(R.layout.apptitle, null);
          actionBar.setDisplayShowTitleEnabled(false);
          actionBar.setCustomView(v);
      }
  }
  </code></pre>
  
  <p>Manifest part for the same:</p>
  
  <pre><code>&lt;activity
              android:name="com.example.travelplanner.MenuActivity"
              android:screenOrientation="portrait" android:configChanges="orientation|keyboardHidden"
              android:uiOptions="splitActionBarWhenNarrow"
              android:label="WeTrip"
              android:theme="@style/MyTheme" &gt;
  </code></pre>
  
  <p>Style.xml part:</p>
  
  <pre><code>&lt;style name="MyTheme" parent="@android:style/Theme.Holo.Light"&gt;
          &lt;item name="android:actionBarStyle"&gt;@style/MyActionBar&lt;/item&gt;
      &lt;/style&gt;
      &lt;style name="MyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar"&gt;
          &lt;item name="android:background"&gt;#F0F1F1&lt;/item&gt;
          &lt;item name="android:backgroundSplit"&gt;#000000&lt;/item&gt;
      &lt;/style&gt;
  </code></pre>
  
  <p>MenuActivity.java</p>
  
  <pre><code>public class MenuActivity extends BaseMenuActivity implements OnItemClickListener{
  
      ActionBar actionBar;
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          //requestWindowFeature(Window.FEATURE_NO_TITLE);
          setContentView(R.layout.activity_menu);
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          // Inflate the menu; this adds items to the action bar if it is present.
          getMenuInflater().inflate(R.menu.menu, menu);
          SearchView searchView = (SearchView) menu.findItem(R.id.menu_action_search).getActionView();
          return true;
      }
  
      @Override
      public boolean onOptionsItemSelected(MenuItem item) {
          // TODO Auto-generated method stub
          switch(item.getItemId()){
              case R.id.menu_action_search:
              {}
              case R.id.menu_action_locate:
              {}
              case R.id.menu_action_mail:
              {}
              case R.id.menu_action_call:
              {}
          }
          return super.onOptionsItemSelected(item);
      }
  
  }
  </code></pre>