@@ -144,6 +144,8 @@ public class Editor {
144144 CharSequence mError ;
145145 boolean mErrorWasChanged ;
146146 ErrorPopup mErrorPopup ;
147+ private int mLastLayoutDirection = -1 ;
148+
147149 /**
148150 * This flag is set if the TextView tries to display an error before it
149151 * is attached to the window (so its position is still unknown).
@@ -288,23 +290,30 @@ private void showError() {
288290 public void setError (CharSequence error , Drawable icon ) {
289291 mError = TextUtils .stringOrSpannedString (error );
290292 mErrorWasChanged = true ;
291- final Drawables dr = mTextView .mDrawables ;
292- if (dr != null ) {
293- switch (mTextView .getLayoutDirection ()) {
293+ final int layoutDirection = mTextView .getLayoutDirection ();
294+ if (mLastLayoutDirection != layoutDirection ) {
295+ final Drawables dr = mTextView .mDrawables ;
296+ switch (layoutDirection ) {
294297 default :
295298 case View .LAYOUT_DIRECTION_LTR :
296- mTextView .setCompoundDrawables (dr .mDrawableLeft , dr .mDrawableTop , icon ,
297- dr .mDrawableBottom );
299+ if (dr != null ) {
300+ mTextView .setCompoundDrawables (dr .mDrawableLeft , dr .mDrawableTop , icon ,
301+ dr .mDrawableBottom );
302+ } else {
303+ mTextView .setCompoundDrawables (null , null , icon , null );
304+ }
298305 break ;
299306 case View .LAYOUT_DIRECTION_RTL :
300- mTextView .setCompoundDrawables (icon , dr .mDrawableTop , dr .mDrawableRight ,
301- dr .mDrawableBottom );
307+ if (dr != null ) {
308+ mTextView .setCompoundDrawables (icon , dr .mDrawableTop , dr .mDrawableRight ,
309+ dr .mDrawableBottom );
310+ } else {
311+ mTextView .setCompoundDrawables (icon , null , null , null );
312+ }
302313 break ;
303314 }
304- } else {
305- mTextView .setCompoundDrawables (null , null , icon , null );
315+ mLastLayoutDirection = layoutDirection ;
306316 }
307-
308317 if (mError == null ) {
309318 if (mErrorPopup != null ) {
310319 if (mErrorPopup .isShowing ()) {
0 commit comments