cocos2d-x的pageview怎么让多个分页挤在一起
展开全部
简单方法实现ViewPage 循环滚动;
在显示前将ViewPager的页面设置到中间即可实现左右循环滚动。
viewPager.setCurrentItem(10000*pageViews.size(), true);
[mw_shl_code=java,true]private class GuidePageAdapter extends PagerAdapter{
@Override
public int getCount() {
return Integer.MAX_VALUE; //Integer.MAX_VALUE最大值;
}
@Override
public boolean isViewFromObject(View arg0, Object arg1) {
return arg0 == arg1;
}
@Override
public int getItemPosition(Object object) {
// TODO Auto-generated method stub
return super.getItemPosition(object);
}
@Override
public void destroyItem(View arg0, int position, Object arg2) {
// TODO Auto-generated method stub
//这里空着不需要代码
}
@Override
public Object instantiateItem(View arg0, int position) {
// TODO Auto-generated method stub
((ViewPager) arg0).removeView(pageViews.get(position%pageViews.size()));
((ViewPager) arg0).addView(pageViews.get(position%pageViews.size()));
return pageViews.get(position%pageViews.size());
}
@Override
public void restoreState(Parcelable arg0, ClassLoader arg1) {
// TODO Auto-generated method stub
}
@Override
public Parcelable saveState() {
// TODO Auto-generated method stub
return null;
}
@Override
public void startUpdate(View arg0) {
// TODO Auto-generated method stub
}
@Override
public void finishUpdate(View arg0) {
// TODO Auto-generated method stub
}
} [/mw_shl_code]
在显示前将ViewPager的页面设置到中间即可实现左右循环滚动。
viewPager.setCurrentItem(10000*pageViews.size(), true);
[mw_shl_code=java,true]private class GuidePageAdapter extends PagerAdapter{
@Override
public int getCount() {
return Integer.MAX_VALUE; //Integer.MAX_VALUE最大值;
}
@Override
public boolean isViewFromObject(View arg0, Object arg1) {
return arg0 == arg1;
}
@Override
public int getItemPosition(Object object) {
// TODO Auto-generated method stub
return super.getItemPosition(object);
}
@Override
public void destroyItem(View arg0, int position, Object arg2) {
// TODO Auto-generated method stub
//这里空着不需要代码
}
@Override
public Object instantiateItem(View arg0, int position) {
// TODO Auto-generated method stub
((ViewPager) arg0).removeView(pageViews.get(position%pageViews.size()));
((ViewPager) arg0).addView(pageViews.get(position%pageViews.size()));
return pageViews.get(position%pageViews.size());
}
@Override
public void restoreState(Parcelable arg0, ClassLoader arg1) {
// TODO Auto-generated method stub
}
@Override
public Parcelable saveState() {
// TODO Auto-generated method stub
return null;
}
@Override
public void startUpdate(View arg0) {
// TODO Auto-generated method stub
}
@Override
public void finishUpdate(View arg0) {
// TODO Auto-generated method stub
}
} [/mw_shl_code]
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询