From 237c1ceea36024cf4194212e713806e3ce8a1c49 Mon Sep 17 00:00:00 2001 From: Romain Guy Date: Tue, 8 Dec 2009 11:30:25 -0800 Subject: Improve exception message thrown when a View's state is of the wrong type. --- core/java/android/view/View.java | 6 +++++- core/java/android/view/ViewDebug.java | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'core/java') diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 1fc3678..d94d0c2 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -5961,7 +5961,11 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility 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"); + 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."); } } diff --git a/core/java/android/view/ViewDebug.java b/core/java/android/view/ViewDebug.java index 4baf612..2fd974e 100644 --- a/core/java/android/view/ViewDebug.java +++ b/core/java/android/view/ViewDebug.java @@ -1300,7 +1300,7 @@ public class ViewDebug { } } - private static Object resolveId(Context context, int id) { + static Object resolveId(Context context, int id) { Object fieldValue; final Resources resources = context.getResources(); if (id >= 0) { -- cgit v1.1