java.lang.IllegalArgumentException: Wrong state class, expecting View State but received class cn.etouch.ecalendar.waterfallview.StaggeredGridView$GridListSavedState instead. This usually happens when two
views of different type have the same id in the same hierarchy. This view's id is id/refresh_gridView. Make sure other views do not use the same id.

依照Log的提示,是id起了冲突。可是我经过细致查看XML布局文件,并没有起冲突的ID。其实,在xml布局文件里常常有重名的id。

网上另一些说通过clean项目。这个也解决不了问题。

我遇到的情形是:FragmentA 中包含FragmentA1,FragmentA2。FragmentA3,FragementA3中有一个自己定义的GridView,当A1,A2和A3之间切换时。程序就会崩溃,并报上述的错误。

id同样?确实可能是ID同样。由于,当A1,A2和A3切换的时候。将A3的gridView状态保存了,当然id也保存下来了。下次再切换到A3就可能出现id同样的情形。

(不知道理解的对不正确?)

这时候须要重写GridView中的onRestoreInstanceState函数:

默认:

@Override

    protected void onRestoreInstanceState(Parcelable state) {

            super.onRestoreInstanceState(state); }

改动为:

@Override

    protected void onRestoreInstanceState(Parcelable state) {

        try {

            super.onRestoreInstanceState(state);

        }catch (Exception e) {}

        state=null;

      }

再次执行程序。问题得到解决

java.lang.IllegalArgumentException: Wrong state classs的更多相关文章

  1. mybatis mapper.xml 写关联查询 运用 resultmap 结果集中 用 association 关联其他表 并且 用 association 的 select 查询值 报错 java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for mybatis.map

    用mybaits 写一个关联查询 查询商品表关联商品规格表,并查询规格表中的数量.价格等,为了sql重用性,利用 association 节点 查询 结果并赋值报错 商品表的mapper文件为Gooo ...

  2. IDEA报错: Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'spring.datasource.url' in value "${spring.datasource.url}"

    运行审核流模块: 在ActivitiServiceApplication模块日志报错: Error starting ApplicationContext. To display the auto-c ...

  3. 解决kylin报错:Failed to create dictionary on <db>.<table>, Caused by: java.lang.IllegalArgumentException: Too high cardinality is not suitable for dictionary

    报错信息: 2017-05-13 15:14:30,035 DEBUG [pool-9-thread-10] dict.DictionaryGenerator:94 : Dictionary clas ...

  4. Java连接MongoDB报错“java.lang.IllegalArgumentException: clusterListener can not be null”的解决办法

    我使用的MongoDB版本是3.6.9. 下面是一个很基础的示例代码,功能就是连接MongoDB: package com.zifeiy.snowflake.handle.etl.mongodb; i ...

  5. hadoop程序问题:java.lang.IllegalArgumentException: Wrong FS: hdfs:/ expected file:///

    Java代码如下: FileSystem fs = FileSystem.get(conf); in = fs.open(new Path("hdfs://192.168.130.54:19 ...

  6. 严重: Error starting static Resources java.lang.IllegalArgumentException:

    严重: Error starting static Resources java.lang.IllegalArgumentException: Document base E:\myworkspace ...

  7. Eclipse启动Tomcat时发生java.lang.IllegalArgumentException: <session-config> element is limited to 1 occurrence

    在学习struts 2时,为了方便,直接从下载的struts的apps目录下的struts2-blank.war压缩包下的WEB-INF\复制的web.xml,当我启动Tomcat时,发生 java. ...

  8. tomcat报错java.lang.IllegalArgumentException: Document base XXXXX does not exist or is not a readable directory

    启动tomcat的时候报如下错误: java.lang.IllegalArgumentException: Document base F:\java\tools\tomcat\me-webapps\ ...

  9. java.lang.IllegalArgumentException: 'sessionFactory' or 'hibernateTemplate' is required

    java.lang.IllegalArgumentException: 'sessionFactory' or 'hibernateTemplate' is required 严重: Exceptio ...

随机推荐

  1. SublimeText3自动补全python提示

    1.SublimeText3下载地址 https://www.sublimetext.com/3 2.安装SublimeText3 3.安装SublimeCodeIntel (1)打开SublimeT ...

  2. 栅栏涂漆(color)

    栅栏涂漆测评 题目描述 zed 最近总是受到 Farmer 的困扰,因此他在自家的门前插了一排栅栏以防农气的入侵.栅栏由 N 个竖条栅栏横向组成,每个竖条栅栏宽度为 1.过了一段时间,zed 觉得栅栏 ...

  3. eclipse 导出burpsuite插件包含第三方lib包

    第一步:右键项目点击export: 2.选择Runable JAR file: 点击Finish后会爆出一个错误(Jar export finished with problems. See deta ...

  4. Distributed Cache Coherence at Scalable Requestor Filter Pipes that Accumulate Invalidation Acknowledgements from other Requestor Filter Pipes Using Ordering Messages from Central Snoop Tag

    A multi-processor, multi-cache system has filter pipes that store entries for request messages sent ...

  5. Android控件点击事件

    1. 介绍 本文介绍了Android控件的点击事件 Android控件点击(onClick)事件可以用如下三种方式来实现 2. 实现onClick方法 在layout的xml中指定onClick方法, ...

  6. Java反射常用API汇总

    “JAVA反射机制是在运行状态中,对于任意一个类,都能够知道这个类的所有属性和方法:对于任意一个对象,都能够调用它的任意方法和属性” 一.类对象的获取 1.通过对象获取 Object obj = ne ...

  7. aliyun

    阿里云启动不了网站 1  将网站的目录属性-安全中加入IUSER_计算机名字的访问权限     和  加入NER SERVICE的访问权限 2 IIS打开网站属性--目录--执行权限改为顺脚本 3  ...

  8. 模板:统计1~n内x的个数

    http://noi.openjudge.cn/ch0105/40/ 40:数1的个数-拓展变形 查看 提交 统计 提问 总时间限制:  1000ms 内存限制:  65536kB 描述 给定一个十进 ...

  9. HDU 5923 Prediction(2016 CCPC东北地区大学生程序设计竞赛 Problem B,并查集)

    题目链接  2016 CCPC东北地区大学生程序设计竞赛 B题 题意  给定一个无向图和一棵树,树上的每个结点对应无向图中的一条边,现在给出$q$个询问, 每次选定树中的一个点集,然后真正被选上的是这 ...

  10. Python的程序结构[1] -> 方法/Method[3] -> 魔术方法 __getattr__ 与代理模式

    __getattr__ 方法 __getattr__ 方法当对象调用内部属性(包括方法等)且未找到对应属性的时候会调用的特殊方法.利用这一特性,可是对函数实现一个代理模式. __getattr__方法 ...