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. SHTSC2017酱油记~~~

    一转眼,SHTSC2017就结束了呢... [前记] noip2016的时候,day2由于各种奇奇怪怪的原因,于是策略上犯错误,然后直接滚粗... 作为一个SHTSC2016年就莫名其妙当上B队队长的 ...

  2. parallel programming. this causual litery nots represents my recent progress in parallel programming in c#.It`s interesting.

    not to say extra words,let`s start the code. pasted below: using System; using System.Collections.Ge ...

  3. zero(NOIP模拟赛 Round 4)

    题目描述 假设x=N!,那么x的末尾有多少个零呢? 输入 一行,一个整数N. 输出 输出只有一个整数,表示x末尾零的个数. 这道题目,我们看一看数据范围, 10^1000肯定是高精啦! 然后我们再想一 ...

  4. dpkg: error processing package bluez (--configure) 解决方法【转】

    转自:http://blog.csdn.net/heray1990/article/details/47803541 在 Ubuntu 执行 sudo apt-get upgrade 时,出现了如下的 ...

  5. Linux中tty框架与uart框架之间的调用关系剖析【转】

    转自:http://developer.51cto.com/art/201209/357501.htm 之前本人在"从串口驱动的移植看linux2.6内核中的驱动模型 platform de ...

  6. WebBrowser(超文本浏览框)控件默认使用IE9,IE10的方法

    C#和易语言都可以使用该方法来变更默认的的IE版本 该文是通过修改注册表的方法实现,测试的时候发现易语言本身也是采用的这种方法 操作方法 打开注册表 HKEY_LOCAL_MACHINE (or HK ...

  7. 纠正网上乱传的android调用Webservice方法。

    1.写作背景: 笔者想实现android调用webservice,可是网上全是不管对与错乱转载的文章,结果不但不能解决问题,只会让人心烦,所以笔者决定将自己整理好的能用的android调用webser ...

  8. kuangbin系列【简单搜索】

    poj-1321棋盘问题[bfs/回溯] Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 36385   Accepted:  ...

  9. Python_Tips[0] -> 关于 import

    关于 import 1 import import可用于导入一个Python的标准模块,包括.py文件或带有__init__.py的文件目录. 在Python中,import一个模块后,若再次impo ...

  10. (寒假集训)Mooo Moo (完全背包)

    Mooo Moo 时间限制: 1 Sec  内存限制: 64 MB提交: 5  解决: 4[提交][状态][讨论版] 题目描述 Farmer John has completely forgotten ...