PagerAdapter changed the adapter's contents without calling PagerAdapter#notifyDataSetChanged
今天开发的时候遇到了如题的异常。上网搜到了个答案: 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()。搜索了代码,确实发现有没有调用的地方。改了就好了。 来源: oschina 链接: https://my.oschina.net/u/268088/blog/789742