PagerAdapter changed the adapter's contents without calling PagerAdapter#notifyDataSetChanged

无人久伴 提交于 2019-12-10 14:54:24

今天开发的时候遇到了如题的异常。上网搜到了个答案:

After ADT 22 the PagerAdapter has gotten very strict about calling notifyDataSetChanged() before calling getCount().  It evidently keeps track of what it thinks the count should be and if this is not the same as what getCount() returns it throws this exception.  So the solution is simply to call notifyDataSetChanged() on the adapter every time the size of the data changes.

解决办法就是必须要在对adapter的data做改变之后马上调用notifyDataSetChanged()。搜索了代码,确实发现有没有调用的地方。改了就好了。

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!