title: How to change the selected tab on button click?
body: <p>I have followed the tutorial found here:</p>
  
  <p><a href="http://www.androidbegin.com/tutorial/implementing-fragment-tabs-in-android/" rel="nofollow">Implementing Fragment Tabs in Android</a></p>
  
  <p>and I have it working properly, but I wanted to be able to switch the fragments on button click, not just on tab selection.  So inside of <code>FragmentTab1()</code> I have added an ImageButton that lets me switch out my fragments, and open <code>FragmentTab2()</code>.  </p>
  
  <p>This is the code inside of <code>FragmentTab1()</code> in <code>OnCreateView()</code>:</p>
  
  <pre><code>@Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
                           Bundle savedInstanceState) {
      View rootView = inflater.inflate(R.layout.fragment_form1, container, false);
      btnFragment1 = (ImageButton) rootView.findViewById(R.id.next);
  
      btnFragment1.setOnClickListener(btnFragmentOnClickListener);
  
      return rootView;
  }
  </code></pre>
  
  <p>This is the code for my button:</p>
  
  <pre><code>Button.OnClickListener btnFragmentOnClickListener
          = new Button.OnClickListener(){
  
      @Override
      public void onClick(View v) {
          // TODO Auto-generated method stub
          Fragment newFragment;
  
          newFragment = new FragmentTab2();
  
          // Create new transaction
          FragmentTransaction transaction = getFragmentManager().beginTransaction();
  
          // Replace whatever is in the fragment_container view with this fragment,
          // and add the transaction to the back stack
          transaction.replace(R.id.fragment_container, newFragment);
          transaction.addToBackStack(null);
  
          // Commit the transaction
          transaction.commit();
      }};
  }
  </code></pre>
  
  <p>This works properly to switch out the fragments. </p>
  
  <p><strong>My question is</strong>: How do I get the selected tab to have the blue line underneath the text in the tab itself?
  Any help would be appreciated!</p>
  
  <p><strong>Edit:</strong> I am not using a TabHost so this makes the solution trickier, I am using ActionBar.TabListener.</p>