我面临的问题是,当屏幕方向从potrait更改为landscape时,应用程序会崩溃,尤其是在显示下拉菜单时。我已经使用onRestoreInstanceState()等编写了多个处理此代码的代码。请告诉我是否遗漏了某些内容。
答案 0 :(得分:0)
发布一次代码..
该特定异常的源代码似乎已使用更有用的错误消息进行了更新:
protected void onRestoreInstanceState(Parcelable state) {
mPrivateFlags |= SAVE_STATE_CALLED;
if (state != BaseSavedState.EMPTY_STATE && state != null) {
throw new IllegalArgumentException("Wrong state class, expecting View State but "
+ "received " + state.getClass().toString() + " instead. This usually happens "
+ "when two views of different type have the same id in the same hierarchy. "
+ "This view's id is " + ViewDebug.resolveId(mContext, getId()) + ". Make sure "
+ "other views do not use the same id.");
}
}
如果使用java代码创建布局,则可能会出现此问题。 理想情况下,您将使用XML进行布局。它会让你的生活变得更加轻松。
希望这会有所帮助..