java.lang.IllegalArgumentException: Wrong state classs
来源:互联网 发布:怎么查淘宝卖家的id 编辑:程序博客网 时间:2024/04/28 16:18
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
- java.lang.IllegalArgumentException: Wrong state classs
- java.lang.IllegalArgumentException: Wrong state classs
- java.lang.IllegalArgumentException: Wrong state class
- java.lang.IllegalArgumentException: Wrong state class, expecting View State but received class andro
- java.lang.IllegalArgumentException: Wrong state class, expecting View State but received
- java.lang.IllegalArgumentException: wrong number of arguments
- java.lang.IllegalArgumentException: wrong number of arguments
- java.lang.IllegalArgumentException: Wrong FS://expected: file:///
- 解析Java反射java.lang.IllegalArgumentException: wrong number of arguments
- java反射 java.lang.IllegalArgumentException: wrong number of arguments
- Java反射异常:java.lang.IllegalArgumentException: wrong number of arguments
- java.lang.IllegalArgumentException: Wrong FS ...异常的解决
- java.lang.IllegalArgumentException: Wrong FS: hdfs:/ expected file:///
- jboss启动出错----java.lang.IllegalArgumentException: Wrong arguments.
- java.lang.IllegalArgumentException: Wrong FS: expected: file:/// – Hadoop
- Hadoop 问题java.lang.IllegalArgumentException Wrong FS: hdfs://192.168
- 反射异常:java.lang.IllegalArgumentException: wrong number of arguments
- POJ 2236 Wireless Network (并查集)
- PyPy 和 CPython 的性能比较测试
- jQuery-1.9+.min.map 404 (Not Found) 错误,了解Source Map
- 第一次c++
- net.ipv4.tcp_tw_recycle参数造成的连接不稳定
- java.lang.IllegalArgumentException: Wrong state classs
- Smartform循环打印
- 【Android】 完美解决ScrollView嵌套ListView滑动冲突(有图有真相)
- POJ 1703 Find them, Catch them (并查集)
- mysql主从同步配置
- HttpClient使用详解
- 第二周上机项目3.1时间类
- strchr, strrchr
- java面试