title: setHomeButtonEnabled(false) returns null while using it for swipe tabs
body: <p>I am trying to develop swipe tabs in my android app. I googled it and tried to implement it by myself. Here is what I did:</p>
  
  <p><strong>MainActivity.java:</strong></p>
  
  <pre><code>package com.example.shiza.swipetabs;
  
  import android.app.ActionBar;
  
  import android.app.FragmentTransaction;
  import android.support.v4.app.FragmentActivity;
  import android.support.v4.app.FragmentPagerAdapter;
  import android.support.v4.view.ViewPager;
  import android.support.v7.app.ActionBarActivity;
  import android.os.Bundle;
  import android.view.Window;
  
  
  public class MainActivity extends FragmentActivity implements ActionBar.TabListener{
      ActionBar bar;
      ViewPager viewPager;
      FragmentPageAdapter ft;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
          setContentView(R.layout.activity_main);
  
  //        viewPager = new ViewPager(this);
          viewPager.setId(R.id.pager);
  
          setContentView(viewPager);
  
          ft = new FragmentPageAdapter(getSupportFragmentManager());
  
          viewPager.setAdapter(ft);
  
          bar = getActionBar();
  
          try {
              bar.setHomeButtonEnabled(false);
          } catch (Exception e) {
              e.printStackTrace();
          }
          bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
  
          bar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE);
  
          bar.addTab(bar.newTab().setText("A").setTabListener(this));
          bar.addTab(bar.newTab().setText("B").setTabListener(this));
          bar.addTab(bar.newTab().setText("C").setTabListener(this));
          viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
              @Override
              public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
  
              }
  
              @Override
              public void onPageSelected(int position) {
                  bar.setSelectedNavigationItem(position);
              }
  
              @Override
              public void onPageScrollStateChanged(int state) {
  
              }
          });
      }
  
      @Override
      public void onTabSelected(ActionBar.Tab tab, FragmentTransaction ft) {
          viewPager.setCurrentItem(tab.getPosition());
      }
  
      @Override
      public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction ft) {
  
      }
  
      @Override
      public void onTabReselected(ActionBar.Tab tab, FragmentTransaction ft) {
  
      }
  }
  </code></pre>
  
  <p><strong>FragmentPageAdapter.java:</strong></p>
  
  <pre><code>package com.example.shiza.swipetabs;
  
  //import android.app.FragmentManager;
  import android.support.v4.app.Fragment;
  import android.support.v4.app.FragmentManager;
  import android.support.v4.app.FragmentPagerAdapter;
  
  /**
   * Created by Shiza on 11-06-2015.
   */
  public class FragmentPageAdapter extends FragmentPagerAdapter{
  
      public FragmentPageAdapter(FragmentManager fm)
      {
          super(fm);
      }
      @Override
      public Fragment getItem(int position) {
  
          switch (position)
          {
              case 1:
                  return new Fragment_a();
  
              case 2:
                  return new Fragment_b();
              case 3:
                  return new Fragment_c();
          }
          return null;
      }
  
      @Override
      public int getCount() {
          return 3;
      }
  }
  </code></pre>
  
  <p>Everything is fine, but when I am getting following warning:</p>
  
  <pre><code>Method invocation 'bar.setHomeButtonEnabled(false)' may produce 'java.lang.NullPointerException
  </code></pre>
  
  <p>At runtime, I got <code>NullPointerException</code> at the same line.<br>
  I searched it on StackOverflow and come to know that I need to use <code>v7.support</code> library. I am unable to implement that. It looks like...</p>
  
  <pre><code> bar = getActionBar();
  </code></pre>
  
  <p>...returns <code>null</code>. Apart from this I am getting a lot of deprecated methods. Please suggest me a better tutorial. I am taking help of <a href="http://www.androidhive.info/2013/10/android-tab-layout-with-swipeable-views-1/" rel="nofollow">this</a>. I have tried all solutions on SO, but none of them work. Please help me to solve this.</p>