OSDN Git Service

Fixed cast exception with selectable text.
authorGilles Debunne <debunne@google.com>
Thu, 7 Jun 2012 17:50:58 +0000 (10:50 -0700)
committerGilles Debunne <debunne@google.com>
Thu, 7 Jun 2012 17:51:06 +0000 (10:51 -0700)
Bug 6550358

The EditText constructor now calls setTextIsSelectable, which uses
getText where the cast exception happens because the EditText is not
yet fully built and its text does not have the right type.

Fixed by using mText directly instead of getText().

Change-Id: I52a2720ae99475881f210ac74464728cab92147e

core/java/android/widget/TextView.java

index 131b075..01617da 100644 (file)
@@ -4656,7 +4656,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
         // mInputType should already be EditorInfo.TYPE_NULL and mInput should be null
 
         setMovementMethod(selectable ? ArrowKeyMovementMethod.getInstance() : null);
-        setText(getText(), selectable ? BufferType.SPANNABLE : BufferType.NORMAL);
+        setText(mText, selectable ? BufferType.SPANNABLE : BufferType.NORMAL);
 
         // Called by setText above, but safer in case of future code changes
         mEditor.prepareCursorControllers();