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.
getChildFragmentManager()
is a method on Fragment
, not on FragmentActivity
. Use getSupportFragmentManager()
on a FragmentActivity
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With