oncreate中
//设置适配器 无限轮播
SyViewPagerAdapter avpa=new SyViewPagerAdapter(list);
sy_vp.setAdapter(avpa);
sy_vp.setCurrentItem(Integer.MAX_VALUE/2-Integer.MAX_VALUE/2%4); //Integer.MAX_VALUE/2%4中4是Viewpager页面的数量(页面集合的长度)
//移除所有的发送信息 重新发送
handler.removeCallbacksAndMessages(null);
handler.sendEmptyMessageDelayed(0,2000);
Handler中
private Handler handler=new Handler(){
public void handleMessage(android.os.Message msg) {
int it=sy_vp.getCurrentItem();
int i=it+1;
sy_vp.setCurrentItem(i);
handler.sendEmptyMessageDelayed(0, 2000);
};
};
适配器中
@Override
public int getCount() {
// TODO Auto-generated method stub
return Integer.MAX_VALUE;
}
@Override
public Object instantiateItem(ViewGroup container, int position) {
View v=list.get(position%list.size());
container.addView(v);
return v;
}