首页>代码>国人写的安卓框架AndBase>/AndBase/src/com/ab/adapter/AbFragmentPagerAdapter.java
/*
 * Copyright (C) 2012 www.amsoft.cn
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.ab.adapter;

import java.util.ArrayList;

import android.app.Fragment;
import android.app.FragmentManager;
import android.support.v13.app.FragmentPagerAdapter;

// TODO: Auto-generated Javadoc

/**
 * © 2012 amsoft.cn
 * 名称:AbFragmentPagerAdapter.java 
 * 描述:一个通用的Fragment适配器
 *
 * @author 还如一梦中
 * @version v1.0
 * @date:2013-11-28 上午10:57:53
 */
public class AbFragmentPagerAdapter extends FragmentPagerAdapter {

	/** The m fragment list. */
	private ArrayList<Fragment> mFragmentList = null;

	/**
	 * Instantiates a new ab fragment pager adapter.
	 * @param mFragmentManager the m fragment manager
	 * @param fragmentList the fragment list
	 */
	public AbFragmentPagerAdapter(FragmentManager mFragmentManager,ArrayList<Fragment> fragmentList) {
		super(mFragmentManager);
		mFragmentList = fragmentList;
	}

	/**
	 * 描述:获取数量.
	 *
	 * @return the count
	 * @see android.support.v4.view.PagerAdapter#getCount()
	 */
	@Override
	public int getCount() {
		return mFragmentList.size();
	}

	/**
	 * 描述:获取索引位置的Fragment.
	 *
	 * @param position the position
	 * @return the item
	 * @see android.support.v4.app.FragmentPagerAdapter#getItem(int)
	 */
	@Override
	public Fragment getItem(int position) {

		Fragment fragment = null;
		if (position < mFragmentList.size()){
			fragment = mFragmentList.get(position);
		}else{
			fragment = mFragmentList.get(0);
		}
		return fragment;

	}
}
最近下载更多
haozhilang  LV8 2023年11月2日
yyyyyyzh  LV8 2023年6月11日
wanfeng_233  LV4 2023年5月29日
sks666  LV5 2023年2月19日
lasherry  LV2 2023年2月14日
快乐的程序员  LV25 2023年1月21日
ABU元帅  LV2 2022年11月7日
787194770  LV10 2022年10月19日
yjycdjb  LV5 2022年5月23日
总有人间一两风  LV8 2022年5月12日
最近浏览更多
syd1988  LV7 3月7日
666ing  LV2 2023年12月26日
不止是六位数  LV7 2023年12月21日
G2andIG  LV5 2023年11月6日
haozhilang  LV8 2023年11月2日
dzlwindy  LV8 2023年8月28日
yyyyyyzh  LV8 2023年6月11日
微信网友_6503436888428544  LV1 2023年6月3日
qazwer11  LV5 2023年5月18日
sks666  LV5 2023年2月19日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友