zoukankan      html  css  js  c++  java
  • 解决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了

  • 相关阅读:
    flex 按钮自定义皮肤
    SQl查询数据库库名,表名、表的列名
    导出到excel文件
    信息安全技术 实验一 JS 实现 Source code CryptoJS
    python学习
    博客园可以直接写可运行的JS,还可以传文件,我爱死你啦 力挺博客园
    Javascript 数的表示与位运算
    交换两个值
    开发Question
    2272012 笔记 开机启动服务
  • 原文地址:https://www.cnblogs.com/Sharley/p/9166675.html
Copyright © 2011-2022 走看看