Java 类android.support.v4.app.FragmentPagerAdapter 实例源码

项目:GitHub    文件:SubjectBookListActivity.java   
@Override
public void initDatas() {
    mDatas = Arrays.asList(getResources().getStringArray(R.array.subject_tabs));

    mTabContents = new ArrayList<>();
    mTabContents.add(SubjectFragment.newInstance("", 0));
    mTabContents.add(SubjectFragment.newInstance("", 1));
    mTabContents.add(SubjectFragment.newInstance("", 2));

    mAdapter = new FragmentPagerAdapter(getSupportFragmentManager()) {
        @Override
        public int getCount() {
            return mTabContents.size();
        }

        @Override
        public Fragment getItem(int position) {
            return mTabContents.get(position);
        }
    };
}
项目:GitHub    文件:BookDetailCommunityActivity.java   
@Override
public void initDatas() {
    mDatas = Arrays.asList(getResources().getStringArray(R.array.bookdetail_community_tabs));

    mTabContents = new ArrayList<>();
    mTabContents.add(BookDetailDiscussionFragment.newInstance(bookId));
    mTabContents.add(BookDetailReviewFragment.newInstance(bookId));

    mAdapter = new FragmentPagerAdapter(getSupportFragmentManager()) {
        @Override
        public int getCount() {
            return mTabContents.size();
        }

        @Override
        public Fragment getItem(int position) {
            return mTabContents.get(position);
        }
    };
}
项目:GitHub    文件:MainActivity.java   
@Override
public void initDatas() {
    startService(new Intent(this, DownloadBookService.class));

    mTencent = Tencent.createInstance("1105670298", MainActivity.this);

    mDatas = Arrays.asList(getResources().getStringArray(R.array.home_tabs));
    mTabContents = new ArrayList<>();
    mTabContents.add(new RecommendFragment());
    mTabContents.add(new CommunityFragment());
    mTabContents.add(new FindFragment());

    mAdapter = new FragmentPagerAdapter(getSupportFragmentManager()) {
        @Override
        public int getCount() {
            return mTabContents.size();
        }

        @Override
        public Fragment getItem(int position) {
            return mTabContents.get(position);
        }
    };
}
项目:GitHub    文件:SubCategoryListActivity.java   
@Override
public void initDatas() {
    mDatas = Arrays.asList(getResources().getStringArray(R.array.sub_tabs));

    mPresenter.attachView(this);
    mPresenter.getCategoryListLv2();

    mTabContents = new ArrayList<>();
    mTabContents.add(SubCategoryFragment.newInstance(cate, "", gender, Constant.CateType.NEW));
    mTabContents.add(SubCategoryFragment.newInstance(cate, "", gender, Constant.CateType.HOT));
    mTabContents.add(SubCategoryFragment.newInstance(cate, "", gender, Constant.CateType.REPUTATION));
    mTabContents.add(SubCategoryFragment.newInstance(cate, "", gender, Constant.CateType.OVER));

    mAdapter = new FragmentPagerAdapter(getSupportFragmentManager()) {
        @Override
        public int getCount() {
            return mTabContents.size();
        }

        @Override
        public Fragment getItem(int position) {
            return mTabContents.get(position);
        }
    };
}
项目:GitHub    文件:SubRankActivity.java   
@Override
public void initDatas() {
    mDatas = Arrays.asList(getResources().getStringArray(R.array.sub_rank_tabs));

    mTabContents = new ArrayList<>();
    mTabContents.add(SubRankFragment.newInstance(week));
    mTabContents.add(SubRankFragment.newInstance(month));
    mTabContents.add(SubRankFragment.newInstance(all));

    mAdapter = new FragmentPagerAdapter(getSupportFragmentManager()) {
        @Override
        public int getCount() {
            return mTabContents.size();
        }

        @Override
        public Fragment getItem(int position) {
            return mTabContents.get(position);
        }
    };
}
项目:SweepRobot    文件:WelcomeActivity.java   
@Override
protected void initData() {

    adapter = new FragmentPagerAdapter(getSupportFragmentManager()) {
        @Override
        public Fragment getItem(int position) {
            return WelcomeFragment.newInstance(position+"");
        }

        @Override
        public int getCount() {
            return 3;
        }
    };

    vp.setAdapter(adapter);

}
项目:MVVM-JueJin    文件:LoopPagerAdapterWrapper.java   
@Override
public Object instantiateItem(ViewGroup container, int position) {
    mViewPager = ((ViewPager) container);
    int realPosition =  (mAdapter instanceof FragmentPagerAdapter || mAdapter instanceof FragmentStatePagerAdapter)
            ? position
            : toRealPosition(position);

    if (mBoundaryCaching) {
        ToDestroy toDestroy = mToDestroy.get(position);
        if (toDestroy != null) {
            mToDestroy.remove(position);
            return toDestroy.object;
        }
    }

    if(realPosition >= 0 && realPosition < getRealCount())
        return mAdapter.instantiateItem(container, realPosition);
    return null;
}
项目:beyondwords    文件:MainActivity.java   
private void initDatas() {

        fragments.add(new ReciteFragment());
        fragments.add(new SocietyFragment());
        fragments.add(new MessageFragment());
        fragments.add(new MeFragment());

        mAdapter = new FragmentPagerAdapter(getSupportFragmentManager()) {
            @Override
            public Fragment getItem(int position) {
                return fragments.get(position);
            }

            @Override
            public int getCount() {
                return fragments.size();
            }
        };
    }
项目:Carousel    文件:ViewPagerTestActivity.java   
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_viewpager);

    viewPager = findViewById(R.id.viewPager);

    fragments = new ArrayList<>();
    fragments.add(ViewPagerFragment.newInstance());
    fragments.add(ViewPagerFragment.newInstance());
    fragments.add(ViewPagerFragment.newInstance());

    viewPager.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager()) {
        @Override
        public Fragment getItem(int position) {
            return fragments.get(position);
        }

        @Override
        public int getCount() {
            return 3;
        }
    });
}
项目:StatusLayout    文件:Main2Activity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mFragments.add(new TestFragment());
    mFragments.add(new TestFragment());
    setContentView(R.layout.activity_main2);
    ViewPager viewPager = findViewById(R.id.viewpager);
    viewPager.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager()) {
        @Override
        public Fragment getItem(int position) {
            return mFragments.get(position);
        }

        @Override
        public int getCount() {
            return mFragments.size();
        }
    });
}
项目:YCUtils    文件:BackHandlerHelper.java   
/**
 * 将back事件分发给ViewPager中的Fragment,{@link #handleBackPress(FragmentManager)} 已经实现了对ViewPager的支持,所以自行决定是否使用该方法
 *
 * @return 如果处理了back键则返回 <b>true</b>
 * @see #handleBackPress(FragmentManager)
 * @see #handleBackPress(Fragment)
 * @see #handleBackPress(FragmentActivity)
 */
public static boolean handleBackPress(ViewPager viewPager) {
    if (viewPager == null) return false;
    PagerAdapter adapter = viewPager.getAdapter();
    if (adapter == null) return false;
    int currentItem = viewPager.getCurrentItem();
    Fragment fragment;
    if (adapter instanceof FragmentPagerAdapter) {
        fragment = ((FragmentPagerAdapter) adapter).getItem(currentItem);
    } else if (adapter instanceof FragmentStatePagerAdapter) {
        fragment = ((FragmentStatePagerAdapter) adapter).getItem(currentItem);
    } else {
        fragment = null;
    }
    return isFragmentBackHandled(fragment);
}
项目:DailyStudy    文件:CoordinatorLayoutActivity.java   
private void initDatas() {
    mIndicator.setTitles(mTitles);

    for (int i = 0; i < mTitles.length; i++) {
        mFragments[i] = TabFragment.newInstance(mTitles[i]);
    }

    mAdapter = new FragmentPagerAdapter(getSupportFragmentManager()) {
        @Override
        public int getCount() {
            return mTitles.length;
        }

        @Override
        public Fragment getItem(int position) {
            return mFragments[position];
        }

    };

    mViewPager.setAdapter(mAdapter);
    mViewPager.setCurrentItem(0);
}
项目:BookReader-master    文件:SubjectBookListActivity.java   
@Override
public void initDatas() {
    mDatas = Arrays.asList(getResources().getStringArray(R.array.subject_tabs));

    mTabContents = new ArrayList<>();
    mTabContents.add(SubjectFragment.newInstance("", 0));
    mTabContents.add(SubjectFragment.newInstance("", 1));
    mTabContents.add(SubjectFragment.newInstance("", 2));

    mAdapter = new FragmentPagerAdapter(getSupportFragmentManager()) {
        @Override
        public int getCount() {
            return mTabContents.size();
        }

        @Override
        public Fragment getItem(int position) {
            return mTabContents.get(position);
        }
    };
}
项目:BookReader-master    文件:BookDetailCommunityActivity.java   
@Override
public void initDatas() {
    mDatas = Arrays.asList(getResources().getStringArray(R.array.bookdetail_community_tabs));

    mTabContents = new ArrayList<>();
    mTabContents.add(BookDetailDiscussionFragment.newInstance(bookId));
    mTabContents.add(BookDetailReviewFragment.newInstance(bookId));

    mAdapter = new FragmentPagerAdapter(getSupportFragmentManager()) {
        @Override
        public int getCount() {
            return mTabContents.size();
        }

        @Override
        public Fragment getItem(int position) {
            return mTabContents.get(position);
        }
    };
}
项目:BookReader-master    文件:MainActivity.java   
@Override
public void initDatas() {
    startService(new Intent(this, DownloadBookService.class));

    mTencent = Tencent.createInstance("1105670298", MainActivity.this);

    mDatas = Arrays.asList(getResources().getStringArray(R.array.home_tabs));
    mTabContents = new ArrayList<>();
    mTabContents.add(new RecommendFragment());
    mTabContents.add(new CommunityFragment());
    mTabContents.add(new FindFragment());

    mAdapter = new FragmentPagerAdapter(getSupportFragmentManager()) {
        @Override
        public int getCount() {
            return mTabContents.size();
        }

        @Override
        public Fragment getItem(int position) {
            return mTabContents.get(position);
        }
    };
}
项目:BookReader-master    文件:SubCategoryListActivity.java   
@Override
public void initDatas() {
    mDatas = Arrays.asList(getResources().getStringArray(R.array.sub_tabs));

    mPresenter.attachView(this);
    mPresenter.getCategoryListLv2();

    mTabContents = new ArrayList<>();
    mTabContents.add(SubCategoryFragment.newInstance(cate, "", gender, Constant.CateType.NEW));
    mTabContents.add(SubCategoryFragment.newInstance(cate, "", gender, Constant.CateType.HOT));
    mTabContents.add(SubCategoryFragment.newInstance(cate, "", gender, Constant.CateType.REPUTATION));
    mTabContents.add(SubCategoryFragment.newInstance(cate, "", gender, Constant.CateType.OVER));

    mAdapter = new FragmentPagerAdapter(getSupportFragmentManager()) {
        @Override
        public int getCount() {
            return mTabContents.size();
        }

        @Override
        public Fragment getItem(int position) {
            return mTabContents.get(position);
        }
    };
}
项目:BookReader-master    文件:SubRankActivity.java   
@Override
public void initDatas() {
    mDatas = Arrays.asList(getResources().getStringArray(R.array.sub_rank_tabs));

    mTabContents = new ArrayList<>();
    mTabContents.add(SubRankFragment.newInstance(week));
    mTabContents.add(SubRankFragment.newInstance(month));
    mTabContents.add(SubRankFragment.newInstance(all));

    mAdapter = new FragmentPagerAdapter(getSupportFragmentManager()) {
        @Override
        public int getCount() {
            return mTabContents.size();
        }

        @Override
        public Fragment getItem(int position) {
            return mTabContents.get(position);
        }
    };
}
项目:ImageClassify    文件:MainActivity.java   
private void initView() {
    listFragment = new ArrayList<>();
    homeFragment = new HomeFragment();
    taskFragment = new TaskFragment();
    rankFragment = new RankFragment();
    meFragment = new MeFragment();
    listFragment.add(homeFragment);
    listFragment.add(taskFragment);
    listFragment.add(rankFragment);
    listFragment.add(meFragment);

    adapter = new FragmentPagerAdapter(getSupportFragmentManager()) {
        @Override
        public Fragment getItem(int position) {
            return listFragment.get(position);
        }

        @Override
        public int getCount() {
            return listFragment.size();
        }
    };
    viewPager.setAdapter(adapter);
}
项目:FragmentBackHandler    文件:BackHandlerHelper.java   
/**
 * 将back事件分发给ViewPager中的Fragment,{@link #handleBackPress(FragmentManager)} 已经实现了对ViewPager的支持,所以自行决定是否使用该方法
 *
 * @return 如果处理了back键则返回 <b>true</b>
 * @see #handleBackPress(FragmentManager)
 * @see #handleBackPress(Fragment)
 * @see #handleBackPress(FragmentActivity)
 */
public static boolean handleBackPress(ViewPager viewPager) {
    if (viewPager == null) return false;

    PagerAdapter adapter = viewPager.getAdapter();

    if (adapter == null) return false;

    int currentItem = viewPager.getCurrentItem();
    Fragment fragment;
    if (adapter instanceof FragmentPagerAdapter) {
        fragment = ((FragmentPagerAdapter) adapter).getItem(currentItem);
    } else if (adapter instanceof FragmentStatePagerAdapter) {
        fragment = ((FragmentStatePagerAdapter) adapter).getItem(currentItem);
    } else {
        fragment = null;
    }
    return isFragmentBackHandled(fragment);
}
项目:SpaceMaterial    文件:MainActivity.java   
private void initViews() {
    // Bottom bar
    BottomNavigationView bottomNavigationView = findById(this, bottom_navigation_view);
    bottomNavigationView.setOnNavigationItemSelectedListener(new OnNavigationItemSelectedListener() {
        @Override
        public boolean onNavigationItemSelected(@NonNull MenuItem item) {
            switch (item.getItemId()) {
                case R.id.tab_iss_location:
                    contentViewPager.setCurrentItem(ISS_LOCATION_FRAGMENT_POSITION, false);
                    break;
                case R.id.tab_people_in_space:
                    contentViewPager.setCurrentItem(PEOPLE_IN_SPACE_FRAGMENT_POSITION, false);
                    break;
                case R.id.tab_iss_pass_times:
                    contentViewPager.setCurrentItem(ISS_PASS_TIMES_FRAGMENT_POSITION, false);
                    break;
            }
            return true;
        }
    });

    // ViewPager
    FragmentPagerAdapter mainPagerAdapter = new MainPagerAdapter(getSupportFragmentManager());
    contentViewPager.setAdapter(mainPagerAdapter);
}
项目:RongChat    文件:MainActivity.java   
private void initMianViewPager() {
    mConversationList = initConversationList();
    mViewPager = (ViewPager) findViewById(R.id.rc_viewpager);
    mFragment.add(mConversationList);
    mFragment.add(ContactFragment.getInstance());
    mFragment.add(FoundFragment.getInstance());
    mFragment.add(MineFragment.getInstance());
    mFragmentPagerAdapter = new FragmentPagerAdapter(getSupportFragmentManager()) {
        @Override
        public Fragment getItem(int position) {
            return mFragment.get(position);
        }

        @Override
        public int getCount() {
            return mFragment.size();
        }
    };
    mViewPager.setAdapter(mFragmentPagerAdapter);
    mViewPager.setOffscreenPageLimit(4);
    mViewPager.setOnPageChangeListener(this);
}
项目:ViewPageIndicator-underline    文件:MainActivity.java   
private void initDatas() {

        for (String data : mDatas) {
            VpSimpleFragment fragment = VpSimpleFragment.newInstance(data);
            mTabContents.add(fragment);
        }

        mAdapter = new FragmentPagerAdapter(getSupportFragmentManager()) {
            @Override
            public int getCount() {
                return mTabContents.size();
            }

            @Override
            public Fragment getItem(int position) {
                return mTabContents.get(position);
            }
        };
    }
项目:stickynavlayout    文件:MainActivity.java   
private void initDatas() {
    mIndicator.setTabItemTitles(mTitles);

    for (int i = 0; i < mTitles.length; i++) {
        mFragments[i] = (TabFragment) TabFragment.newInstance(mTitles[i]);
    }

    mAdapter = new FragmentPagerAdapter(getSupportFragmentManager()) {
        @Override
        public int getCount() {
            return mTitles.length;
        }

        @Override
        public Fragment getItem(int position) {
            return mFragments[position];
        }

    };

    mViewPager.setAdapter(mAdapter);
    mViewPager.setCurrentItem(0);
}
项目:stickynavlayout    文件:MainActivity.java   
private void initDatas() {
    mIndicator.setTabItemTitles(mTitles);

    for (int i = 0; i < mTitles.length; i++) {
        mFragments[i] = (TabFragment) TabFragment.newInstance(mTitles[i]);
    }

    mAdapter = new FragmentPagerAdapter(getSupportFragmentManager()) {
        @Override
        public int getCount() {
            return mTitles.length;
        }

        @Override
        public Fragment getItem(int position) {
            return mFragments[position];
        }

    };

    mViewPager.setAdapter(mAdapter);
    mViewPager.setCurrentItem(0);
}
项目:BookReader    文件:SubjectBookListActivity.java   
@Override
public void initDatas() {
    mDatas = Arrays.asList(getResources().getStringArray(R.array.subject_tabs));

    mTabContents = new ArrayList<>();
    mTabContents.add(SubjectFragment.newInstance("", 0));
    mTabContents.add(SubjectFragment.newInstance("", 1));
    mTabContents.add(SubjectFragment.newInstance("", 2));

    mAdapter = new FragmentPagerAdapter(getSupportFragmentManager()) {
        @Override
        public int getCount() {
            return mTabContents.size();
        }

        @Override
        public Fragment getItem(int position) {
            return mTabContents.get(position);
        }
    };
}
项目:BookReader    文件:BookDetailCommunityActivity.java   
@Override
public void initDatas() {
    mDatas = Arrays.asList(getResources().getStringArray(R.array.bookdetail_community_tabs));

    mTabContents = new ArrayList<>();
    mTabContents.add(BookDetailDiscussionFragment.newInstance(bookId));
    mTabContents.add(BookDetailReviewFragment.newInstance(bookId));

    mAdapter = new FragmentPagerAdapter(getSupportFragmentManager()) {
        @Override
        public int getCount() {
            return mTabContents.size();
        }

        @Override
        public Fragment getItem(int position) {
            return mTabContents.get(position);
        }
    };
}
项目:BookReader    文件:MainActivity.java   
@Override
public void initDatas() {
    startService(new Intent(this, DownloadBookService.class));

    mTencent = Tencent.createInstance("1105670298", MainActivity.this);

    mDatas = Arrays.asList(getResources().getStringArray(R.array.home_tabs));
    mTabContents = new ArrayList<>();
    mTabContents.add(new RecommendFragment());
    mTabContents.add(new CommunityFragment());
    mTabContents.add(new FindFragment());

    mAdapter = new FragmentPagerAdapter(getSupportFragmentManager()) {
        @Override
        public int getCount() {
            return mTabContents.size();
        }

        @Override
        public Fragment getItem(int position) {
            return mTabContents.get(position);
        }
    };
}
项目:BookReader    文件:SubCategoryListActivity.java   
@Override
public void initDatas() {
    mDatas = Arrays.asList(getResources().getStringArray(R.array.sub_tabs));

    mPresenter.attachView(this);
    mPresenter.getCategoryListLv2();

    mTabContents = new ArrayList<>();
    mTabContents.add(SubCategoryFragment.newInstance(cate, "", gender, Constant.CateType.NEW));
    mTabContents.add(SubCategoryFragment.newInstance(cate, "", gender, Constant.CateType.HOT));
    mTabContents.add(SubCategoryFragment.newInstance(cate, "", gender, Constant.CateType.REPUTATION));
    mTabContents.add(SubCategoryFragment.newInstance(cate, "", gender, Constant.CateType.OVER));

    mAdapter = new FragmentPagerAdapter(getSupportFragmentManager()) {
        @Override
        public int getCount() {
            return mTabContents.size();
        }

        @Override
        public Fragment getItem(int position) {
            return mTabContents.get(position);
        }
    };
}
项目:BookReader    文件:SubRankActivity.java   
@Override
public void initDatas() {
    mDatas = Arrays.asList(getResources().getStringArray(R.array.sub_rank_tabs));

    mTabContents = new ArrayList<>();
    mTabContents.add(SubRankFragment.newInstance(week));
    mTabContents.add(SubRankFragment.newInstance(month));
    mTabContents.add(SubRankFragment.newInstance(all));

    mAdapter = new FragmentPagerAdapter(getSupportFragmentManager()) {
        @Override
        public int getCount() {
            return mTabContents.size();
        }

        @Override
        public Fragment getItem(int position) {
            return mTabContents.get(position);
        }
    };
}
项目:SwipeDelMenuLayout    文件:ViewPagerActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_view_pager);
    mViewPager = (ViewPager) findViewById(R.id.viewPager);
    mViewPager.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager()) {
        @Override
        public Fragment getItem(int position) {
            return FullDemoFragment.newInstance(position);
        }

        @Override
        public int getCount() {
            return 3;
        }
    });
}
项目:nono-android    文件:TestRoom.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_testroom);
    viewPager = (ViewPager)findViewById(R.id.view_pager);
    ballTabLayout =(BallTabLayout)findViewById(R.id.ball_tab_layout);

    viewPager.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager()) {
        @Override
        public int getCount() {
            return 3;
        }

        @Override
        public Fragment getItem(int position) {
            return FragmentWithNum.newInstance(position);
        }
    });
    ballTabLayout.setupWithViewPager(viewPager);
}
项目:umeng_community_android    文件:CommentTabFragment.java   
@Override
protected void initWidgets() {

    mTitles = getResources().getStringArray(
            ResFinder.getResourceId(ResType.ARRAY, "umeng_comm_comments_tabs"));

    mIndicator = (ViewPagerIndicator) findViewById(ResFinder
            .getId("umeng_comm_comment_indicator"));
    mViewPager = (ViewPager) findViewById(ResFinder.getId("umeng_comm_comment_viewPager"));
    mIndicator.setTabItemTitles(mTitles);
    mAdapter = new FragmentPagerAdapter(getFragmentManager()) {

        @Override
        public int getCount() {
            return mTitles.length;
        }

        @Override
        public Fragment getItem(int pos) {
            return getFragment(pos);
        }
    };
    mViewPager.setAdapter(mAdapter);
    // 设置关联的ViewPager
    mIndicator.setViewPager(mViewPager, 0);
}
项目:umeng_community_android    文件:TopicDetailActivity.java   
private void initView() {
    mIndicator = (ViewPagerIndicator) findViewById(ResFinder.getId("indicator"));
    mViewPager = (ViewPager) findViewById(ResFinder.getId("viewPager"));
    mIndicator.setTabItemTitles(mTitles);
    mAdapter = new FragmentPagerAdapter(getSupportFragmentManager()) {

        @Override
        public int getCount() {
            return mTitles.length;
        }

        @Override
        public Fragment getItem(int pos) {
            return getFragment(pos);
        }
    };
    mViewPager.setAdapter(mAdapter);
    // 设置关联的ViewPager
    mIndicator.setViewPager(mViewPager, 0);
    // 初始化Header的控件跟数据
    initHeader();
    initTitle();
}
项目:AndroidGeek    文件:CommentTabFragment.java   
@Override
protected void initWidgets() {

    mTitles = getResources().getStringArray(
            ResFinder.getResourceId(ResType.ARRAY, "umeng_comm_comments_tabs"));

    mIndicator = (ViewPagerIndicator) findViewById(ResFinder
            .getId("umeng_comm_comment_indicator"));
    mViewPager = (ViewPager) findViewById(ResFinder.getId("umeng_comm_comment_viewPager"));
    mIndicator.setTabItemTitles(mTitles);
    mAdapter = new FragmentPagerAdapter(getFragmentManager()) {

        @Override
        public int getCount() {
            return mTitles.length;
        }

        @Override
        public Fragment getItem(int pos) {
            return getFragment(pos);
        }
    };
    mViewPager.setAdapter(mAdapter);
    // 设置关联的ViewPager
    mIndicator.setViewPager(mViewPager, 0);
}
项目:AndroidGeek    文件:TopicDetailActivity.java   
private void initView() {
    mIndicator = (ViewPagerIndicator) findViewById(ResFinder.getId("indicator"));
    mViewPager = (ViewPager) findViewById(ResFinder.getId("viewPager"));
    mIndicator.setTabItemTitles(mTitles);
    mAdapter = new FragmentPagerAdapter(getSupportFragmentManager()) {

        @Override
        public int getCount() {
            return mTitles.length;
        }

        @Override
        public Fragment getItem(int pos) {
            return getFragment(pos);
        }
    };
    mViewPager.setAdapter(mAdapter);
    // 设置关联的ViewPager
    mIndicator.setViewPager(mViewPager, 0);
    // 初始化Header的控件跟数据
    initHeader();
    initTitle();
}
项目:AndroidGradientUI    文件:MainActivity.java   
private void initFragments() {
    mTabs.add(ChatsFragment.newInstance("", ""));
    mTabs.add(ContactsFragment.newInstance("", ""));
    mTabs.add(DiscoverFragment.newInstance("", ""));
    mTabs.add(AboutMeFragment.newInstance("", ""));

    mAdapter = new FragmentPagerAdapter(getSupportFragmentManager()) {

        @Override
        public int getCount() {
            return mTabs.size();
        }

        @Override
        public Fragment getItem(int arg0) {
            return mTabs.get(arg0);
        }
    };

    mViewPager.setAdapter(mAdapter);
    mViewPager.setOnPageChangeListener(this);
}
项目:MagicHeaderViewPager    文件:MagicHeaderViewPager.java   
public void setPagerAdapter(FragmentPagerAdapter pagerAdapter) {
    if(!(pagerAdapter instanceof OuterPagerAdapter)) {
        throw new IllegalArgumentException("MagicHeaderViewPager's " +
                "FragmentPagerAdapter must implements interface OuterPagerAdapter!");
    }

    mPagerAdapter = pagerAdapter;

    ((OuterPagerAdapter)mPagerAdapter).setOuterScroller(this);

    if(mViewPager != null) {
        mViewPager.setAdapter(mPagerAdapter);
        if(mPagerSlidingTabStrip !=null) {
            mPagerSlidingTabStrip.setViewPager(mViewPager);
        }
    }
}
项目:yolosh-android    文件:MainFragment.java   
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onViewCreated(view, savedInstanceState);

    FragmentPagerAdapter adapter = new MainFragmentPageAdaper(
            getChildFragmentManager());

    ViewPager pager = (ViewPager) view.findViewById(R.id.pager);
    pager.setAdapter(adapter);

    TitlePageIndicator indicator = (TitlePageIndicator) view
            .findViewById(R.id.indicator);
    indicator.setViewPager(pager);

    pager.setCurrentItem(1);
}
项目:yolosh-android    文件:MainFragment.java   
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onViewCreated(view, savedInstanceState);

    FragmentPagerAdapter adapter = new MainFragmentPageAdaper(
            getChildFragmentManager());

    ViewPager pager = (ViewPager) view.findViewById(R.id.pager);
    pager.setAdapter(adapter);

    TitlePageIndicator indicator = (TitlePageIndicator) view
            .findViewById(R.id.indicator);
    indicator.setViewPager(pager);

    pager.setCurrentItem(1);
}
项目:talkback    文件:ProcessorScrollPositionTest.java   
private void setUpViewPager() {
    setContentView(R.layout.view_pager);
    final ViewPager pager = (ViewPager) getViewForId(R.id.test_pager);
    final FragmentManager fragmentManager = getActivity().getSupportFragmentManager();

    getInstrumentation().runOnMainSync(new Runnable() {
        @Override
        public void run() {
            pager.setAdapter(new FragmentPagerAdapter(fragmentManager) {
                @Override
                public Fragment getItem(int position) {
                    return new TestFragment(ITEMS[position]);
                }

                @Override
                public int getCount() {
                    return ITEMS.length;
                }
            });
        }
    });
    getInstrumentation().waitForIdleSync();
}