The application‘s PagerAdapter changed the adapter‘s contents without calling PagerAdapter

The application's PagerAdapter changed the adapter's contents without calling PagerAdapter#notifyDataSetChanged! Expected adapter item count: 6, found: 0
 

最近程序碰到这个报错,记录一下

问题在adapter 中,

override fun destroyItem(container: ViewGroup, position: Int, `object`: Any) {
    container.removeView(`object` as View)
}

要写成container.removeView(`object` as View)

而不是 container.removeView(views.get(position))

上一篇:牛客练习赛50


下一篇:K8S集群以及dashboard部署