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


log信息如下:10-10 12:31:14.186: E/AndroidRuntime(22835): 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.example.app:id/viewpager Pager class: class android.support.v4.view.ViewPager Problematic adapter: class com.example.Share.ViewPagerAdapter

解決方法 http://www.cnblogs.com/ivan240/archive/2013/07/23/3208570.html:

在初始化ViewPager時,應先給Adapter初始化內容后再將該adapter傳給ViewPager,
如果不這樣處理,在更新adapter的內容后,應該調用一下adapter的notifyDataSetChanged方法,
否則在ADT22以上使用會報The application's PagerAdapter changed the adapter's contents without calling PagerAdapter#notifyDataSetChanged的異常,
具體原因可參考:http://stackoverflow.com/questions/16756131/fragmentstatepageradapter-stopped-working-after-updating-to-adt-22

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM