您的位置:首页 > 移动开发

常见错误之java.lang.IllegalStateException: The application’s PagerAdapter changed the adapter’s cont。。。

2015-08-31 10:58 399 查看
如果在logcat日志中出现以下错误:

java.lang.IllegalStateException: The application's PagerAdapter changed the adapter's contents without calling PagerAdapter#notifyDataSetChanged! Expected adapter item count: 0, found: 4 Pager id: com.activity_test.logo:id/viewpager Pager class:
class android.support.v4.view.ViewPager Problematic adapter: class com.activity_test.logo.ViewPagerAdapter。

解决方法:

在初始化ViewPager时,应先给Adapter初始化内容后再将该adapter传给ViewPager,如果不这样处理,在更新

adapter的内容后,应该调用一下adapter的notifyDataSetChanged方法,否则在ADT22以上使用会报这个错。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  android