ViewPager 里面嵌套Fragment
class Aadapter extends FragmentPagerAdapter{
public Aadapter(FragmentManager fm) {
super(fm);
// TODO Auto-generated constructor stub
}
@Override
public Fragment getItem(int arg0) {
// TODO Auto-generated method stub
return jihe.get(arg0);
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return jihe.size();
}
}
纯粹的ViewPager
//创建一个适配器
PagerAdapter pa = new PagerAdapter() {
@Override
public boolean isViewFromObject(View arg0, Object arg1) {
// TODO Auto-generated method stub
return (arg0==arg1);
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return pager.size();
}
public Object instantiateItem(android.view.ViewGroup container, int position) {
//得到要显示的新页面
View v =pager.get(position);
//添加可以重复使用
container.addView(v);
return v;
};
public void destroyItem(android.view.ViewGroup container, int position, Object object) {
//得到要删除的
View v =pager.get(position);
//删除
container.removeView(v);
};
};