Augustus Francis
Augustus Francis

Reputation: 2670

Using SectionsPagerAdapter android

I have a sectionsPagerAdapter that is used as the adapter for a ViewPager.

    mSectionsPagerAdapter = new SectionsPagerAdapter(
            getSupportFragmentManager());

    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mSectionsPagerAdapter);

I have 3 fragments and I want to switch between 2 fragments when a button is clicked?

Upvotes: 3

Views: 18328

Answers (1)

PandaPaul
PandaPaul

Reputation: 156

I'm gonna guess that your SectionsPagerAdapter was automatically generated when you created a new activity using ADT and specified a navigation type with tabs. If that's the case, then your SectionsPagerAdapter is extending FragmentPagerAdapter, whose documentation is located here.

If you really want to use a ViewPager for what you're talking about, check out that link to the Android developer reference. It sounds, though, like you want to do something more akin to what's discussed in this Q/A. Maybe you could elaborate a bit on what you're looking to accomplish?

Upvotes: 10

Related Questions