Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/220.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用SpagerAdapter android_Android_Android Fragments - Fatal编程技术网

使用SpagerAdapter android

使用SpagerAdapter android,android,android-fragments,Android,Android Fragments,我有一个sectionsPagerAdapter,用作ViewPager的适配器 mSectionsPagerAdapter = new SectionsPagerAdapter( getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager);

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

    mSectionsPagerAdapter = new SectionsPagerAdapter(
            getSupportFragmentManager());

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

我有3个片段,我想在单击按钮时在2个片段之间切换?

我猜您的SectionsPagerAdapter是在您使用ADT创建新活动并使用选项卡指定导航类型时自动生成的。如果是这样,那么您的SectionsPagerAdapter将扩展FragmentPagerAdapter


如果你真的想用一个ViewPager来表达你所说的,请查看Android开发者参考资料的链接。不过,这听起来像是你想做一些更类似的事情。也许您可以详细说明一下您希望实现的目标?

我已经通过了链接,我已经完成了研究并获得了结果。谢谢……)