使用SectionsPagerAdapter机器人 [英] Using SectionsPagerAdapter android

查看:456
本文介绍了使用SectionsPagerAdapter机器人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有用作一个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开发者参考。这听起来,不过,就像你想要做的事更类似于<一href="http://stackoverflow.com/questions/5658675/replacing-a-fragment-with-another-fragment-inside-activity-group">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?

这篇关于使用SectionsPagerAdapter机器人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆