• 解决java.lang.IllegalStateException: The application’s PagerAdapter changed the adapter’s content


    A界面中有viewpager的动态加载,从界面A跳到界面B,再finish掉B返回A时报出此异常。

    java.lang.IllegalStateException: 
    The application's PagerAdapter changed the adapter's contents without calling PagerAdapter#notifyDataSetChanged!
    Expected adapter item count: 0, found: 1 Pager id: com.##.##.android:id/vp_pager Pager class: class android.support.v4.view.ViewPager Problematic adapter: class com.##.contacts.quickcontact.Activity$ViewPagerAdapter
    07-15 09:49:21.060: E/com.##.##.##.Application(12378): at android.support.v4.view.ViewPager.populate(ViewPager.java:959) 07-15 09:49:21.060: E/com.##.##.##.Application(12378): at android.support.v4.view.ViewPager.populate(ViewPager.java:911) 07-15 09:49:21.060: E/com.##.##.##.Application(12378): at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1432) 07-15 09:49:21.060: E/com.##.##.##.Application(12378): at android.view.View.measure(View.java:15518) 07-15 09:49:21.060: E/com.##.##.##.Application(12378): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4825) 07-15 09:49:21.060: E/com.##.##.##.Application(12378): at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404) 07-15 09:49:21.060: E/com.##.##.##.Application(12378): at android.widget.LinearLayout.measureVertical(LinearLayout.java:695) 07-15 09:49:21.060: E/com.##.##.##.Application(12378): at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)

    我的解决办法是

    在界面A的onResume()方法中调用这个viewpager的adapter.notifyDataSetChanged()方法,这样就OK了

  • 相关阅读:
    面向对象与类
    引用数据类型
    方法
    java for 语句的用法
    java 数组
    Scanner与Random
    java基本语法
    java介绍及安装。
    数据库设计
    NFS相关、NFS服务端安装配置、exportfs命令、nfs客户端的问题
  • 原文地址:https://www.cnblogs.com/Sharley/p/9166675.html
Copyright © 2020-2023  润新知