异常信息:java.lang.IndexOutOfBoundsException: index=3 count=2

 

在instantiateItem各个条目View的时候。会有

container.addView(view, 0);

这样一行代码。如果写成

container.addView(view, position);

那么就会报错, java.lang.IndexOutOfBoundsException: index=3 count=2,打印Log,会发现position地 值从0,1, size()-1,只有3个position值,很显然是不对的。

 

查看源码:

 * @param index the position at which to add the child

  

应该是添加子view的时候,默认添加0位置,类似于堆栈的效果,而不是按着position动态添加位置》。。。。

相关文章:

  • 2021-06-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-10
  • 2021-12-10
  • 2021-11-29
猜你喜欢
  • 2021-12-27
  • 2021-05-08
  • 2021-07-18
  • 2022-01-27
  • 2022-01-17
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案