两个关于View.SavedState 的异常分析

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.*****/com.******.RootActivity}: java.lang.ClassCastException: android.view.AbsSavedState$1 cannot be cast to android.widget.ScrollView$SavedState

从错误分析来看应该layout 文件中 有一个ScrollView 的 id 与其他 View 的 id 发生了重复造成的

Unable to start activity ComponentInfo{com.*****/com.*******.UnlockGesturePasswordActivity}: java.lang.IllegalArgumentException: Wrong state class, expecting View State but received class android.view.View$BaseSavedState instead. This usually happens when two views of different type have the same id in the same hierarchy. This view's id is id/gesturepwd_unlock_lockview. Make sure other views do not use the same id.
开始以为与上面一样,有View 的 id 发生了重复。 后来搜索一下并没有发现。 后来查看code 发现
SavedState 没有创建CREATOR 导致的

private static class SavedState extends BaseSavedState {
public static final Parcelable.Creator<SavedState> CREATOR = new Creator<SavedState>() {
   public SavedState createFromParcel(Parcel in) {
      return new SavedState(in);
   }

   public SavedState[] newArray(int size) {
      return new SavedState[size];
   }
};



评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值