title: How to hide individual Tab from ActionBar in Android 4
body: <p>I am developing an app in <code>Android 4</code>. I have three <code>tabs</code> in my app. What my requirement is, I want to show only 1st tab in the beginning, and after clicking on some button from tab 1, I want to show 2nd Tab, after clicking on button, the 3rd tab will be visible.</p>
  
  <p>As Tabs in <code>Android 3</code> on-wards,  does not have <code>setVisibility</code> method, Please tell me how to <code>show/hide</code> <code>particular tab</code> in my case. </p>
  
  <p>Any help will be appreciated.</p>
  
  <p>Thank you.</p>
  
  <p><strong>UPDATE:</strong> onClick of button, I have added this code:</p>
  
  <pre><code>ActionBar actionbar = getActivity().getActionBar();
                  ActionBar.Tab Tab2 = actionbar.newTab().setText("XYZ");
                  ActionBar.Tab Tab3 = actionbar.newTab().setText("PQR");
  
                  Fragment Tab2Fragment = new BFragment();
                  Fragment Tab3Fragment = new CFragment();
  
                  Tab2.setTabListener(new MyTabsListener(Tab2Fragment));
                  Tab3.setTabListener(new MyTabsListener(Tab3Fragment));
                  actionbar.addTab(Tab2);
                  actionbar.addTab(Tab3);
  </code></pre>
  
  <p>But still its not working..</p>
  
  <p><strong>UPDATE:</strong> Now I can see two tabs coming, but I am getting NPE:</p>
  
  <pre><code>06-08 20:57:58.101: E/AndroidRuntime(17070): java.lang.NullPointerException
  
  06-08 20:57:58.101: E/AndroidRuntime(17070):    at de.arvidg.exampleactionbartabs.AFragment.onActivityCreated(AFragment.java:116)
  06-08 20:57:58.101: E/AndroidRuntime(17070):    at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:847)
  06-08 20:57:58.101: E/AndroidRuntime(17070):    at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1032)
  06-08 20:57:58.101: E/AndroidRuntime(17070):    at android.app.BackStackRecord.run(BackStackRecord.java:622)
  06-08 20:57:58.101: E/AndroidRuntime(17070):    at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1382)
  06-08 20:57:58.101: E/AndroidRuntime(17070):    at android.app.FragmentManagerImpl$1.run(FragmentManager.java:426)
  06-08 20:57:58.101: E/AndroidRuntime(17070):    at android.os.Handler.handleCallback(Handler.java:605)
  06-08 20:57:58.101: E/AndroidRuntime(17070):    at android.os.Handler.dispatchMessage(Handler.java:92)
  06-08 20:57:58.101: E/AndroidRuntime(17070):    at android.os.Looper.loop(Looper.java:137)
  06-08 20:57:58.101: E/AndroidRuntime(17070):    at android.app.ActivityThread.main(ActivityThread.java:4424)
  06-08 20:57:58.101: E/AndroidRuntime(17070):    at java.lang.reflect.Method.invokeNative(Native Method)
  06-08 20:57:58.101: E/AndroidRuntime(17070):    at java.lang.reflect.Method.invoke(Method.java:511)
  06-08 20:57:58.101: E/AndroidRuntime(17070):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
  06-08 20:57:58.101: E/AndroidRuntime(17070):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
  06-08 20:57:58.101: E/AndroidRuntime(17070):    at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p>This is my onCreateView and onActivityCreated in AFragment are:</p>
  
  <pre><code>@Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
              Bundle savedInstanceState) {
          // Inflate the layout for this fragment
          return inflater.inflate(R.layout.afragment, container, false);
      }
  
  /* (non-Javadoc)
       * @see android.app.Fragment#onActivityCreated(android.os.Bundle)
       */
      @Override
      public void onActivityCreated(Bundle savedInstanceState) {
          super.onActivityCreated(savedInstanceState);
          appContext = AFragment.this;
          mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
          if (mBluetoothAdapter == null) {
              Toast.makeText(getActivity(), "NO Bluetooth Available", Toast.LENGTH_LONG);
              getActivity().finish();
              return;
          }
          final Button connectBtn = (Button) getActivity().findViewById(R.id.connect_btn);
          connectBtn.setClickable(true); // NPE is occurring here...
  }
  </code></pre>