title: Implementing a TabListener using the Support Library
body: <p>I am trying to implement Tab Navigation, but I want to make sure people that have older versions of Android can still use my application. </p>
  
  <p>The app in mind ATM is fairly simple, I just want to be able to understand how to implement the layout and then I'll add the missing bits. </p>
  
  <p>Anyhow, I have a Container Activity that extends <strong>Fragment Activity</strong> (to ensure compatibility), and this Activity creates a TabView using an <strong>ActionBar</strong> (I believe my problem resides here). The app will try to create three tabs and add them to the ActionBar, and I want to make sure the user can scroll back and forth using lateral navigation. </p>
  
  <p>Here is TabListener I am trying to implement: </p>
  
  <pre><code>public static class TabListener&lt;T extends Fragment&gt; implements ActionBar.TabListener {
  
      private Fragment mFragment;
      private final Activity mActivity;
      private final String mTag;
      private final Class&lt;T&gt; mClass;
  
      public TabListener(Activity activity, String tag, Class&lt;T&gt; clz) {
          mActivity = activity;
          mTag = tag;
          mClass = clz;
      }
  
      public void onTabSelected(Tab tab, FragmentTransaction ft) {
          if (mFragment == null) {
              mFragment = Fragment.instantiate(mActivity, mClass.getName());
              ft.add(android.R.id.content, mFragment, mTag);
          } else {
              ft.attach(mFragment);
          }
      }
  
      public void onTabUnselected(Tab tab, FragmentTransaction ft) {
          if (mFragment != null) {
              ft.detach(mFragment);
          }
      }
  
      public void onTabReselected(Tab tab, FragmentTransaction ft) {
      }
  }
  </code></pre>
  
  <p>Here are my imports, because I wanted to make sure I was using the support library: </p>
  
  <pre><code>import android.app.ActionBar;
  import android.app.ActionBar.Tab;
  import android.app.Activity;
  import android.os.Bundle;
  import android.support.v4.app.Fragment;
  import android.support.v4.app.FragmentActivity;
  import android.support.v4.app.FragmentTransaction;
  import android.support.v4.view.ViewPager;
  import android.view.Menu;
  </code></pre>
  
  <p>However, Eclipse is giving me issues with the <strong>TabListener</strong> methods. It is telling me the following: "The type LayoutContainer.TabListener must implement the inherited abstract method ActionBar.TabListener.onTabSelected(ActionBar.Tab, FragmentTransaction)"</p>
  
  <p>When I select <strong>Add unimplemented methods</strong> Eclipse basically adds the <strong>OnTabSelected OnTabReselected</strong> and <strong>OnTabUnselected</strong> methods, but this time, passing the non-support version of the Fragment (<strong>android..app.Fragment</strong>) as a parameter. </p>
  
  <p>Any ideas on how to make another implementation of lateral navigation through the support library to ensure compatibility? </p>