From 42e14d74f3a1e146091e627ae3067651c6dab104 Mon Sep 17 00:00:00 2001 From: Joe Onorato Date: Thu, 11 Mar 2010 14:51:17 -0800 Subject: [PATCH] Throw a better error message when the automatic onClick handling doesn't work. Change-Id: I61729e26f76a2ab8825e892cd6c70c06f0955e4c --- core/java/android/view/View.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 7a0c4456d11d7..e8bb736da6408 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -2078,8 +2078,14 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility mHandler = getContext().getClass().getMethod(handlerName, View.class); } catch (NoSuchMethodException e) { + int id = getId(); + String idText = id == NO_ID ? "" : " with id '" + + getContext().getResources().getResourceEntryName( + id) + "'"; throw new IllegalStateException("Could not find a method " + - handlerName + "(View) in the activity", e); + handlerName + "(View) in the activity " + + getContext().getClass() + " for onClick handler" + + " on view " + View.this.getClass() + idText, e); } }