使用SectionsPagerAdapter机器人机器人、SectionsPagerAdapter

2023-09-04 07:03:08 作者:每分每秒゛念着一个傻瓜

我有用作一个ViewPager适配器一个sectionsPagerAdapter

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);

我有3个片段,我要的是点击一个按钮时2片段之间进行切换?

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

推荐答案

我要猜你SectionsPagerAdapter当您创建使用ADT一个新的活动,并指定导航类型与标签自动生成。如果是这样的话,那么你的SectionsPagerAdapter正在扩大FragmentPagerAdapter,的文档,这里。

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.

如果你真的想用一个ViewPager什么你在说什么,看看这个链接到Android开发者参考。这听起来,不过,就像你想要做的事更类似于what's在这个Q / A 讨论。也许你可以详细一点你在找什么来实现?

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?