Skip to content

关于IllegalStateException的异常 #77

@Silent-boy

Description

@Silent-boy

如果图片不满四张会报出IllegalStateException的异常错误,需要手动重写instantiateItem()和destroyItem()方法,其中主要操作在前者,后者将父类destroyItem()方法注释掉就行了,建议作者在LoopPagerAdapter中修改instantiateItem()方法如下:
@OverRide
public Object instantiateItem(ViewGroup container, int position) {
int realPosition = position%getRealCount();
View itemView = findViewByPosition(container,realPosition);
ViewParent vp=itemView.getParent();
if(vp!=null){
ViewGroup vg=(ViewGroup)vp;
vp.removeView(itenmView);
}
container.addView(itemView);
return itemView;
}

个人建议,仅供参考!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions