Android - ViewPager使用PagerAdapter,instantiateItem时出现IndexOutOfBoundsException

在使用PagerAdapter的时候,会有instantiateItem函数需要自己去重写。

最后一句   假如写成

((ViewPager) container).addView(v, position);

会报错 :IndexOutOfBoundsException

将position 改成 0  就可以啦

((ViewPager) container).addView(v, 0);

posted @ 2015-07-20 14:37  Maydow  阅读(1050)  评论(0编辑  收藏  举报