title: FragmentPagerAdapter troubles and woes: Constructor Undefined
body: <p><strong>Edit: I have reworked some of my code to try and get past the error</strong> (but now the app crashes on launch). First, my class now extends FragmentActivity so that I can access the method, getSupportFragmentManager();. Then, within on create, I changed my constructor: </p>
  
  <pre><code>mTabsAdapter = new TabsAdapter(this.getSupportFragmentManager(), this, mViewPager);
  </code></pre>
  
  <p>From there, in my subclass, I changed the code to reflect this:</p>
  
  <pre><code>public TabsAdapter(FragmentManager fm, Activity activity, ViewPager pager) {
      super(fm);
      mContext = activity;
      mActionBar = activity.getActionBar();
      mViewPager = pager;
      mViewPager.setAdapter(this);
      mViewPager.setOnPageChangeListener(this);
  }
  </code></pre>
  
  <p><strong>As I said, it still crashes, any ideas at this point?</strong></p>
  
  <p><em>Begin original question:</em>
  I have the following error: “The constructor FragmentPagerAdapter(FragmentManager) is undefined”*</p>
  
  <p>When I try to execute the following line: </p>
  
  <p><code>super(activity.getFragmentManager());</code> this line follows my <code>public TabsAdapter(Activity activity, ViewPager pager) {</code> which is extending <strong>FragmentPagerAdapter</strong>. </p>
  
  <p>Basically, I am trying to get my 8+ fragment app (8 fragment, one activity which hosts a set of ActionBar tabs linked to each fragment [only one is seen here for brevity's sake "loginTab"]). </p>
  
  <p>Here’s my whole code:</p>
  
  <p><strong>Edit: Pages that I have used for reference:</strong> 
  <a href="http://developer.android.com/reference/android/support/v4/view/ViewPager.html">http://developer.android.com/reference/android/support/v4/view/ViewPager.html</a></p>
  
  <p><a href="http://thepseudocoder.wordpress.com/2011/10/05/android-page-swiping-using-viewpager/">http://thepseudocoder.wordpress.com/2011/10/05/android-page-swiping-using-viewpager/</a></p>
  
  <pre><code>package com.davekelley.polling;
  
  import java.util.ArrayList;
  import android.app.ActionBar;
  import android.app.ActionBar.Tab;
  import android.app.Activity;
  import android.content.Context;
  import android.os.Bundle;
  import android.util.Log;
  import android.widget.Button;
  import android.support.v4.app.Fragment;
  import android.support.v4.app.FragmentActivity;
  import android.support.v4.app.FragmentManager;
  import android.support.v4.app.FragmentPagerAdapter;
  import android.support.v4.app.FragmentTransaction;
  import android.support.v4.view.ViewPager;
  import android.support.v4.view.ViewPager.OnPageChangeListener;
  
  public class Polling extends Activity {
  
      private ViewPager mViewPager;
      private TabsAdapter mTabsAdapter;
  
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          mViewPager = new ViewPager(this);
          mViewPager.setId(R.id.pager);
          setContentView(mViewPager);
          final ActionBar bar = getActionBar();
          bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
          bar.setDisplayShowTitleEnabled(false);
          bar.setDisplayShowHomeEnabled(false);
          mTabsAdapter = new TabsAdapter(this, mViewPager);
          mTabsAdapter.addTab(bar.newTab().setText(“Simple”),
          LoginFragment.class, null);
          mTabsAdapter.addTab(bar.newTab().setText(“Simple”),
          EconFragment.class, null);
          mTabsAdapter.addTab(bar.newTab().setText(“Simple”),
          PoliticsFragment.class, null);
  
          if (savedInstanceState != null) {
              bar.setSelectedNavigationItem(savedInstanceState.getInt(“tab”, 0));
          }
      }
      protected void onSaveInstanceState(Bundle outState) {
          super.onSaveInstanceState(outState);
          outState.putInt(“tab”, getActionBar().getSelectedNavigationIndex());
      }
  
      public static class TabsAdapter extends FragmentPagerAdapter
      implements ActionBar.TabListener, ViewPager.OnPageChangeListener {
          private final Context mContext;
          private final ActionBar mActionBar;
          private final ViewPager mViewPager;
          private final ArrayList mTabs = new ArrayList();
  
          static final class TabInfo {
              private final Class clss;
              private final Bundle args;
  
              TabInfo(Class _class, Bundle _args) {
                  clss = _class;
                  args = _args;
              }
          }
  
          public TabsAdapter(Activity activity, ViewPager pager) {
              super(activity.getFragmentManager());
              mContext = activity;
              mActionBar = activity.getActionBar();
              mViewPager = pager;
              mViewPager.setAdapter(this);
              mViewPager.setOnPageChangeListener(this);
          }
  
          public void addTab(ActionBar.Tab tab, Class clss, Bundle args) {
              TabInfo info = new TabInfo(clss, args);
              tab.setTag(info);
              tab.setTabListener(this);
              mTabs.add(info);
              mActionBar.addTab(tab);
              notifyDataSetChanged();
          }
  
          public int getCount() {
              return mTabs.size();
          }
  
          public Fragment getItem(int position) {
              TabInfo info = mTabs.get(position);
              return Fragment.instantiate(mContext, info.clss.getName(), info.args);
          }
  
          public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
          }
  
          public void onPageSelected(int position) {
              mActionBar.setSelectedNavigationItem(position);
          }
  
          public void onPageScrollStateChanged(int state) {
          }
  
          public void onTabSelected(Tab tab, FragmentTransaction ft) {
              Object tag = tab.getTag();
              for (int i=0; i&lt;mTabs.size(); i++) {
                  if (mTabs.get(i) == tag) {
                      mViewPager.setCurrentItem(i);
                  }
              }
          }
  
          public void onTabUnselected(Tab tab, FragmentTransaction ft) {
          }
  
          public void onTabReselected(Tab tab, FragmentTransaction ft) {
          }
  
          public void onTabReselected(Tab tab, android.app.FragmentTransaction ft) {
          }
  
          public void onTabSelected(Tab tab, android.app.FragmentTransaction ft) {
          }
  
          public void onTabUnselected(Tab tab, android.app.FragmentTransaction ft) {
          }
      }
  }
  </code></pre>
  
  <p>Any idea what's going on here and what I can do to fix it? My Fragment classes are very simple at the moment, but will eventually load data from an SQL server (at the meantime, they just return a simple inflated layout).</p>