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. HDU1251统计难题---Trie Tree

    map巧过 #include <stdio.h> #include <string.h> #include <map> #include <string> ...

  2. (九)经典_STM32_ADC多通道采样的例子

    STM32 ADC多通道转换描述:用ADC连续采集11路模拟信号,并由DMA传输到内存.ADC配置为扫描并且连续转换模式,ADC的时钟配置为12MHZ.在每次转换结束后,由DMA循环将转换的数据传输到 ...

  3. 在windows 10 64bit系统上安装python 3.6 64bit的numpy模块

    1.查找自己的python版本对照的whl文件(cp36代表的是版本) 地址:https://pypi.python.org/pypi/numpy 2.下载完毕执行一下命令即可 pip install ...

  4. thinkphp函数学习(3): C函数详解

    function C($name=null, $value=null,$default=null) { static $_config = array(); // 无参数时获取所有 if (empty ...

  5. zclip笔记:解决zclip失效问题

    在一个子页面里想实现一键复制到剪贴版的功能,使用zclip插件,用jquery的方式实现时出现了诡异问题.复制功能平时正常,当页面中所列的内容过多时,一键复制的功能失效. 这个问题相当不好定位,先说结 ...

  6. HDU 3237 Tree(树链剖分)(线段树区间取反,最大值)

    Tree Time Limit: 5000MS   Memory Limit: 131072K Total Submissions: 9123   Accepted: 2411 Description ...

  7. Oracle remove duplicate

    DELETE FROM your_table WHERE rowid not in (SELECT MIN(rowid) FROM your_table GROUP BY column1, colum ...

  8. liunx安装telnet

    安装环境:CentOS 6.4  一.安装telnet 1.检测telnet-server的rpm包是否安装  [root@localhost ~]# rpm -qa telnet-server 若无 ...

  9. Delphi CRC32Verify控件

    unit CRC32Verify; interface uses  Windows, Messages, SysUtils, Classes, Forms; CONST    table:  ARRA ...

  10. Working with the NSOperationQueue Class

    Multi-tasking prevents apps from freezing. In most programming languages, achieving this is a bit tr ...