7

I have a SherlockFragmentActivity, this Activity have a SectionsPagerAdapter and a ViewPager. When I call the constructor of the SectionsPagerAdapter with getChildFragmentManager() method, it shows me this error message:

The method getChildFragmentManager() is undefined for the type ViewPagerActivity

This is my code:

public class ViewPagerActivity extends SherlockFragmentActivity implements OnPageChangeListener, OnQueryTextListener{

private SectionsPagerAdapter sectionsPagerAdapter;
private ViewPager viewPager;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.layout_view_pager);

    sectionsPagerAdapter = new SectionsPagerAdapter(getChildFragmentManager(), this);

    viewPager = (ViewPager) findViewById(R.id.pager);
    viewPager.setAdapter(sectionsPagerAdapter);
    viewPager.setOnPageChangeListener(this);

    this.getMovements();

    this.getPrizes();

    this.getVouchers();

    this.createDropdownlist(); 
}

I'm using ActionBarSherlock and I updated the android-support-v4.jar using "Android Tools - Add Support Library" in my project, also on ActionBarSherlock project.

I'm doing this because I need to have a ListFragment inside a Fragment that I use like a page on my ViewPager.

Blo
  • 11,903
  • 5
  • 45
  • 99
Mark Comix
  • 1,878
  • 7
  • 28
  • 44

1 Answers1

24

getChildFragmentManager() is a method on Fragment, not on FragmentActivity. Use getSupportFragmentManager() on a FragmentActivity.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • oh, what A mistake I made. Sorry for that. I have a problem using Fragment inside fragment, I'm trying a lot of things (this was one of this) and I didn't see that. Again, sorry for my mistake – Mark Comix Jun 05 '13 at 17:19