Texto desenhável na edição de text não atualizando após erro

Editair text no Android não permite alterair o draw depois do setError . Eu usei direito drawable paira o campo de senha, mas se o erro entrair no campo da senha não permitirá mudair o sorteio depois. antes do erro, ele funciona bem.

<EditText android:id="@+id/edt_reg_password" style="@style/editText_full_view" android:layout_height="wrap_content" android:layout_below="@id/edt_reg_email" android:layout_mairginTop="@dimen/padding_normal" android:drawableLeft="@mipmap/ic_action_password" android:drawableRight="@mipmap/ic_action_password_visibility" android:drawablePadding="@dimen/padding_normal" android:hint="@string/hint_password" android:inputType="textPassword" android:maxLength="25" android:paddingLeft="@dimen/padding_normal" tools:visibility="visible" /> 

Código Java paira alterair o tempo de execução do ícone do olho

  • Vista EditText girada personalizada com seleção de trabalho, localization do cursor, etc.
  • EditText em ListView com windowSoftInputMode adjustPan
  •  private void setPasswordDrawable() { final Drawable showpass_icon = getResources().getDrawable(R.mipmap.ic_action_password_visibility); final Drawable hidepass_icon = getResources().getDrawable(R.mipmap.ic_action_password_visibility_off); final Drawable pass_drawable = getResources().getDrawable(R.mipmap.ic_action_password); pass_drawable.setBounds(0, 0, pass_drawable.getIntrinsicWidth(), pass_drawable.getIntrinsicHeight()); //edtPassword.setCompoundDrawables(pass_drawable, null, showpass_icon, null); edtPassword.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { if (edtPassword.getCompoundDrawables()[2] == null) { return false; } if (event.getAction() != MotionEvent.ACTION_UP) { return false; } if (event.getX() > edtPassword.getWidth() - edtPassword.getPaddingRight() - showpass_icon.getIntrinsicWidth()) { if (isPasswordVisible) { runOnUiThread(new Runnable() { @Oviewride public void run() { //edtPassword.setError(null); edtPassword.setTransformationMethod( PasswordTransformationMethod.getInstance()); edtPassword.setSelection(edtPassword.getText().length()); showpass_icon.setBounds(0, 0, showpass_icon.getIntrinsicWidth(), showpass_icon.getIntrinsicHeight()); edtPassword.setCompoundDrawables(pass_drawable, null, showpass_icon, null); } }); isPasswordVisible = false; } else { runOnUiThread(new Runnable() { @Oviewride public void run() { //edtPassword.setError(null); edtPassword.setTransformationMethod( HideReturnsTransformationMethod.getInstance()); edtPassword.setSelection(edtPassword.getText().length()); hidepass_icon.setBounds(0, 0, hidepass_icon.getIntrinsicWidth(), hidepass_icon.getIntrinsicHeight()); edtPassword.setCompoundDrawables(pass_drawable, null, hidepass_icon, null); } }); isPasswordVisible = true; } } return false; } }); } { private void setPasswordDrawable() { final Drawable showpass_icon = getResources().getDrawable(R.mipmap.ic_action_password_visibility); final Drawable hidepass_icon = getResources().getDrawable(R.mipmap.ic_action_password_visibility_off); final Drawable pass_drawable = getResources().getDrawable(R.mipmap.ic_action_password); pass_drawable.setBounds(0, 0, pass_drawable.getIntrinsicWidth(), pass_drawable.getIntrinsicHeight()); //edtPassword.setCompoundDrawables(pass_drawable, null, showpass_icon, null); edtPassword.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { if (edtPassword.getCompoundDrawables()[2] == null) { return false; } if (event.getAction() != MotionEvent.ACTION_UP) { return false; } if (event.getX() > edtPassword.getWidth() - edtPassword.getPaddingRight() - showpass_icon.getIntrinsicWidth()) { if (isPasswordVisible) { runOnUiThread(new Runnable() { @Oviewride public void run() { //edtPassword.setError(null); edtPassword.setTransformationMethod( PasswordTransformationMethod.getInstance()); edtPassword.setSelection(edtPassword.getText().length()); showpass_icon.setBounds(0, 0, showpass_icon.getIntrinsicWidth(), showpass_icon.getIntrinsicHeight()); edtPassword.setCompoundDrawables(pass_drawable, null, showpass_icon, null); } }); isPasswordVisible = false; } else { runOnUiThread(new Runnable() { @Oviewride public void run() { //edtPassword.setError(null); edtPassword.setTransformationMethod( HideReturnsTransformationMethod.getInstance()); edtPassword.setSelection(edtPassword.getText().length()); hidepass_icon.setBounds(0, 0, hidepass_icon.getIntrinsicWidth(), hidepass_icon.getIntrinsicHeight()); edtPassword.setCompoundDrawables(pass_drawable, null, hidepass_icon, null); } }); isPasswordVisible = true; } } return false; } }); } retornair falso; private void setPasswordDrawable() { final Drawable showpass_icon = getResources().getDrawable(R.mipmap.ic_action_password_visibility); final Drawable hidepass_icon = getResources().getDrawable(R.mipmap.ic_action_password_visibility_off); final Drawable pass_drawable = getResources().getDrawable(R.mipmap.ic_action_password); pass_drawable.setBounds(0, 0, pass_drawable.getIntrinsicWidth(), pass_drawable.getIntrinsicHeight()); //edtPassword.setCompoundDrawables(pass_drawable, null, showpass_icon, null); edtPassword.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { if (edtPassword.getCompoundDrawables()[2] == null) { return false; } if (event.getAction() != MotionEvent.ACTION_UP) { return false; } if (event.getX() > edtPassword.getWidth() - edtPassword.getPaddingRight() - showpass_icon.getIntrinsicWidth()) { if (isPasswordVisible) { runOnUiThread(new Runnable() { @Oviewride public void run() { //edtPassword.setError(null); edtPassword.setTransformationMethod( PasswordTransformationMethod.getInstance()); edtPassword.setSelection(edtPassword.getText().length()); showpass_icon.setBounds(0, 0, showpass_icon.getIntrinsicWidth(), showpass_icon.getIntrinsicHeight()); edtPassword.setCompoundDrawables(pass_drawable, null, showpass_icon, null); } }); isPasswordVisible = false; } else { runOnUiThread(new Runnable() { @Oviewride public void run() { //edtPassword.setError(null); edtPassword.setTransformationMethod( HideReturnsTransformationMethod.getInstance()); edtPassword.setSelection(edtPassword.getText().length()); hidepass_icon.setBounds(0, 0, hidepass_icon.getIntrinsicWidth(), hidepass_icon.getIntrinsicHeight()); edtPassword.setCompoundDrawables(pass_drawable, null, hidepass_icon, null); } }); isPasswordVisible = true; } } return false; } }); } } private void setPasswordDrawable() { final Drawable showpass_icon = getResources().getDrawable(R.mipmap.ic_action_password_visibility); final Drawable hidepass_icon = getResources().getDrawable(R.mipmap.ic_action_password_visibility_off); final Drawable pass_drawable = getResources().getDrawable(R.mipmap.ic_action_password); pass_drawable.setBounds(0, 0, pass_drawable.getIntrinsicWidth(), pass_drawable.getIntrinsicHeight()); //edtPassword.setCompoundDrawables(pass_drawable, null, showpass_icon, null); edtPassword.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { if (edtPassword.getCompoundDrawables()[2] == null) { return false; } if (event.getAction() != MotionEvent.ACTION_UP) { return false; } if (event.getX() > edtPassword.getWidth() - edtPassword.getPaddingRight() - showpass_icon.getIntrinsicWidth()) { if (isPasswordVisible) { runOnUiThread(new Runnable() { @Oviewride public void run() { //edtPassword.setError(null); edtPassword.setTransformationMethod( PasswordTransformationMethod.getInstance()); edtPassword.setSelection(edtPassword.getText().length()); showpass_icon.setBounds(0, 0, showpass_icon.getIntrinsicWidth(), showpass_icon.getIntrinsicHeight()); edtPassword.setCompoundDrawables(pass_drawable, null, showpass_icon, null); } }); isPasswordVisible = false; } else { runOnUiThread(new Runnable() { @Oviewride public void run() { //edtPassword.setError(null); edtPassword.setTransformationMethod( HideReturnsTransformationMethod.getInstance()); edtPassword.setSelection(edtPassword.getText().length()); hidepass_icon.setBounds(0, 0, hidepass_icon.getIntrinsicWidth(), hidepass_icon.getIntrinsicHeight()); edtPassword.setCompoundDrawables(pass_drawable, null, hidepass_icon, null); } }); isPasswordVisible = true; } } return false; } }); } retornair falso; private void setPasswordDrawable() { final Drawable showpass_icon = getResources().getDrawable(R.mipmap.ic_action_password_visibility); final Drawable hidepass_icon = getResources().getDrawable(R.mipmap.ic_action_password_visibility_off); final Drawable pass_drawable = getResources().getDrawable(R.mipmap.ic_action_password); pass_drawable.setBounds(0, 0, pass_drawable.getIntrinsicWidth(), pass_drawable.getIntrinsicHeight()); //edtPassword.setCompoundDrawables(pass_drawable, null, showpass_icon, null); edtPassword.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { if (edtPassword.getCompoundDrawables()[2] == null) { return false; } if (event.getAction() != MotionEvent.ACTION_UP) { return false; } if (event.getX() > edtPassword.getWidth() - edtPassword.getPaddingRight() - showpass_icon.getIntrinsicWidth()) { if (isPasswordVisible) { runOnUiThread(new Runnable() { @Oviewride public void run() { //edtPassword.setError(null); edtPassword.setTransformationMethod( PasswordTransformationMethod.getInstance()); edtPassword.setSelection(edtPassword.getText().length()); showpass_icon.setBounds(0, 0, showpass_icon.getIntrinsicWidth(), showpass_icon.getIntrinsicHeight()); edtPassword.setCompoundDrawables(pass_drawable, null, showpass_icon, null); } }); isPasswordVisible = false; } else { runOnUiThread(new Runnable() { @Oviewride public void run() { //edtPassword.setError(null); edtPassword.setTransformationMethod( HideReturnsTransformationMethod.getInstance()); edtPassword.setSelection(edtPassword.getText().length()); hidepass_icon.setBounds(0, 0, hidepass_icon.getIntrinsicWidth(), hidepass_icon.getIntrinsicHeight()); edtPassword.setCompoundDrawables(pass_drawable, null, hidepass_icon, null); } }); isPasswordVisible = true; } } return false; } }); } } private void setPasswordDrawable() { final Drawable showpass_icon = getResources().getDrawable(R.mipmap.ic_action_password_visibility); final Drawable hidepass_icon = getResources().getDrawable(R.mipmap.ic_action_password_visibility_off); final Drawable pass_drawable = getResources().getDrawable(R.mipmap.ic_action_password); pass_drawable.setBounds(0, 0, pass_drawable.getIntrinsicWidth(), pass_drawable.getIntrinsicHeight()); //edtPassword.setCompoundDrawables(pass_drawable, null, showpass_icon, null); edtPassword.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { if (edtPassword.getCompoundDrawables()[2] == null) { return false; } if (event.getAction() != MotionEvent.ACTION_UP) { return false; } if (event.getX() > edtPassword.getWidth() - edtPassword.getPaddingRight() - showpass_icon.getIntrinsicWidth()) { if (isPasswordVisible) { runOnUiThread(new Runnable() { @Oviewride public void run() { //edtPassword.setError(null); edtPassword.setTransformationMethod( PasswordTransformationMethod.getInstance()); edtPassword.setSelection(edtPassword.getText().length()); showpass_icon.setBounds(0, 0, showpass_icon.getIntrinsicWidth(), showpass_icon.getIntrinsicHeight()); edtPassword.setCompoundDrawables(pass_drawable, null, showpass_icon, null); } }); isPasswordVisible = false; } else { runOnUiThread(new Runnable() { @Oviewride public void run() { //edtPassword.setError(null); edtPassword.setTransformationMethod( HideReturnsTransformationMethod.getInstance()); edtPassword.setSelection(edtPassword.getText().length()); hidepass_icon.setBounds(0, 0, hidepass_icon.getIntrinsicWidth(), hidepass_icon.getIntrinsicHeight()); edtPassword.setCompoundDrawables(pass_drawable, null, hidepass_icon, null); } }); isPasswordVisible = true; } } return false; } }); } } private void setPasswordDrawable() { final Drawable showpass_icon = getResources().getDrawable(R.mipmap.ic_action_password_visibility); final Drawable hidepass_icon = getResources().getDrawable(R.mipmap.ic_action_password_visibility_off); final Drawable pass_drawable = getResources().getDrawable(R.mipmap.ic_action_password); pass_drawable.setBounds(0, 0, pass_drawable.getIntrinsicWidth(), pass_drawable.getIntrinsicHeight()); //edtPassword.setCompoundDrawables(pass_drawable, null, showpass_icon, null); edtPassword.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { if (edtPassword.getCompoundDrawables()[2] == null) { return false; } if (event.getAction() != MotionEvent.ACTION_UP) { return false; } if (event.getX() > edtPassword.getWidth() - edtPassword.getPaddingRight() - showpass_icon.getIntrinsicWidth()) { if (isPasswordVisible) { runOnUiThread(new Runnable() { @Oviewride public void run() { //edtPassword.setError(null); edtPassword.setTransformationMethod( PasswordTransformationMethod.getInstance()); edtPassword.setSelection(edtPassword.getText().length()); showpass_icon.setBounds(0, 0, showpass_icon.getIntrinsicWidth(), showpass_icon.getIntrinsicHeight()); edtPassword.setCompoundDrawables(pass_drawable, null, showpass_icon, null); } }); isPasswordVisible = false; } else { runOnUiThread(new Runnable() { @Oviewride public void run() { //edtPassword.setError(null); edtPassword.setTransformationMethod( HideReturnsTransformationMethod.getInstance()); edtPassword.setSelection(edtPassword.getText().length()); hidepass_icon.setBounds(0, 0, hidepass_icon.getIntrinsicWidth(), hidepass_icon.getIntrinsicHeight()); edtPassword.setCompoundDrawables(pass_drawable, null, hidepass_icon, null); } }); isPasswordVisible = true; } } return false; } }); } }); private void setPasswordDrawable() { final Drawable showpass_icon = getResources().getDrawable(R.mipmap.ic_action_password_visibility); final Drawable hidepass_icon = getResources().getDrawable(R.mipmap.ic_action_password_visibility_off); final Drawable pass_drawable = getResources().getDrawable(R.mipmap.ic_action_password); pass_drawable.setBounds(0, 0, pass_drawable.getIntrinsicWidth(), pass_drawable.getIntrinsicHeight()); //edtPassword.setCompoundDrawables(pass_drawable, null, showpass_icon, null); edtPassword.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { if (edtPassword.getCompoundDrawables()[2] == null) { return false; } if (event.getAction() != MotionEvent.ACTION_UP) { return false; } if (event.getX() > edtPassword.getWidth() - edtPassword.getPaddingRight() - showpass_icon.getIntrinsicWidth()) { if (isPasswordVisible) { runOnUiThread(new Runnable() { @Oviewride public void run() { //edtPassword.setError(null); edtPassword.setTransformationMethod( PasswordTransformationMethod.getInstance()); edtPassword.setSelection(edtPassword.getText().length()); showpass_icon.setBounds(0, 0, showpass_icon.getIntrinsicWidth(), showpass_icon.getIntrinsicHeight()); edtPassword.setCompoundDrawables(pass_drawable, null, showpass_icon, null); } }); isPasswordVisible = false; } else { runOnUiThread(new Runnable() { @Oviewride public void run() { //edtPassword.setError(null); edtPassword.setTransformationMethod( HideReturnsTransformationMethod.getInstance()); edtPassword.setSelection(edtPassword.getText().length()); hidepass_icon.setBounds(0, 0, hidepass_icon.getIntrinsicWidth(), hidepass_icon.getIntrinsicHeight()); edtPassword.setCompoundDrawables(pass_drawable, null, hidepass_icon, null); } }); isPasswordVisible = true; } } return false; } }); } } private void setPasswordDrawable() { final Drawable showpass_icon = getResources().getDrawable(R.mipmap.ic_action_password_visibility); final Drawable hidepass_icon = getResources().getDrawable(R.mipmap.ic_action_password_visibility_off); final Drawable pass_drawable = getResources().getDrawable(R.mipmap.ic_action_password); pass_drawable.setBounds(0, 0, pass_drawable.getIntrinsicWidth(), pass_drawable.getIntrinsicHeight()); //edtPassword.setCompoundDrawables(pass_drawable, null, showpass_icon, null); edtPassword.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { if (edtPassword.getCompoundDrawables()[2] == null) { return false; } if (event.getAction() != MotionEvent.ACTION_UP) { return false; } if (event.getX() > edtPassword.getWidth() - edtPassword.getPaddingRight() - showpass_icon.getIntrinsicWidth()) { if (isPasswordVisible) { runOnUiThread(new Runnable() { @Oviewride public void run() { //edtPassword.setError(null); edtPassword.setTransformationMethod( PasswordTransformationMethod.getInstance()); edtPassword.setSelection(edtPassword.getText().length()); showpass_icon.setBounds(0, 0, showpass_icon.getIntrinsicWidth(), showpass_icon.getIntrinsicHeight()); edtPassword.setCompoundDrawables(pass_drawable, null, showpass_icon, null); } }); isPasswordVisible = false; } else { runOnUiThread(new Runnable() { @Oviewride public void run() { //edtPassword.setError(null); edtPassword.setTransformationMethod( HideReturnsTransformationMethod.getInstance()); edtPassword.setSelection(edtPassword.getText().length()); hidepass_icon.setBounds(0, 0, hidepass_icon.getIntrinsicWidth(), hidepass_icon.getIntrinsicHeight()); edtPassword.setCompoundDrawables(pass_drawable, null, hidepass_icon, null); } }); isPasswordVisible = true; } } return false; } }); } }); private void setPasswordDrawable() { final Drawable showpass_icon = getResources().getDrawable(R.mipmap.ic_action_password_visibility); final Drawable hidepass_icon = getResources().getDrawable(R.mipmap.ic_action_password_visibility_off); final Drawable pass_drawable = getResources().getDrawable(R.mipmap.ic_action_password); pass_drawable.setBounds(0, 0, pass_drawable.getIntrinsicWidth(), pass_drawable.getIntrinsicHeight()); //edtPassword.setCompoundDrawables(pass_drawable, null, showpass_icon, null); edtPassword.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { if (edtPassword.getCompoundDrawables()[2] == null) { return false; } if (event.getAction() != MotionEvent.ACTION_UP) { return false; } if (event.getX() > edtPassword.getWidth() - edtPassword.getPaddingRight() - showpass_icon.getIntrinsicWidth()) { if (isPasswordVisible) { runOnUiThread(new Runnable() { @Oviewride public void run() { //edtPassword.setError(null); edtPassword.setTransformationMethod( PasswordTransformationMethod.getInstance()); edtPassword.setSelection(edtPassword.getText().length()); showpass_icon.setBounds(0, 0, showpass_icon.getIntrinsicWidth(), showpass_icon.getIntrinsicHeight()); edtPassword.setCompoundDrawables(pass_drawable, null, showpass_icon, null); } }); isPasswordVisible = false; } else { runOnUiThread(new Runnable() { @Oviewride public void run() { //edtPassword.setError(null); edtPassword.setTransformationMethod( HideReturnsTransformationMethod.getInstance()); edtPassword.setSelection(edtPassword.getText().length()); hidepass_icon.setBounds(0, 0, hidepass_icon.getIntrinsicWidth(), hidepass_icon.getIntrinsicHeight()); edtPassword.setCompoundDrawables(pass_drawable, null, hidepass_icon, null); } }); isPasswordVisible = true; } } return false; } }); } } private void setPasswordDrawable() { final Drawable showpass_icon = getResources().getDrawable(R.mipmap.ic_action_password_visibility); final Drawable hidepass_icon = getResources().getDrawable(R.mipmap.ic_action_password_visibility_off); final Drawable pass_drawable = getResources().getDrawable(R.mipmap.ic_action_password); pass_drawable.setBounds(0, 0, pass_drawable.getIntrinsicWidth(), pass_drawable.getIntrinsicHeight()); //edtPassword.setCompoundDrawables(pass_drawable, null, showpass_icon, null); edtPassword.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { if (edtPassword.getCompoundDrawables()[2] == null) { return false; } if (event.getAction() != MotionEvent.ACTION_UP) { return false; } if (event.getX() > edtPassword.getWidth() - edtPassword.getPaddingRight() - showpass_icon.getIntrinsicWidth()) { if (isPasswordVisible) { runOnUiThread(new Runnable() { @Oviewride public void run() { //edtPassword.setError(null); edtPassword.setTransformationMethod( PasswordTransformationMethod.getInstance()); edtPassword.setSelection(edtPassword.getText().length()); showpass_icon.setBounds(0, 0, showpass_icon.getIntrinsicWidth(), showpass_icon.getIntrinsicHeight()); edtPassword.setCompoundDrawables(pass_drawable, null, showpass_icon, null); } }); isPasswordVisible = false; } else { runOnUiThread(new Runnable() { @Oviewride public void run() { //edtPassword.setError(null); edtPassword.setTransformationMethod( HideReturnsTransformationMethod.getInstance()); edtPassword.setSelection(edtPassword.getText().length()); hidepass_icon.setBounds(0, 0, hidepass_icon.getIntrinsicWidth(), hidepass_icon.getIntrinsicHeight()); edtPassword.setCompoundDrawables(pass_drawable, null, hidepass_icon, null); } }); isPasswordVisible = true; } } return false; } }); } } private void setPasswordDrawable() { final Drawable showpass_icon = getResources().getDrawable(R.mipmap.ic_action_password_visibility); final Drawable hidepass_icon = getResources().getDrawable(R.mipmap.ic_action_password_visibility_off); final Drawable pass_drawable = getResources().getDrawable(R.mipmap.ic_action_password); pass_drawable.setBounds(0, 0, pass_drawable.getIntrinsicWidth(), pass_drawable.getIntrinsicHeight()); //edtPassword.setCompoundDrawables(pass_drawable, null, showpass_icon, null); edtPassword.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { if (edtPassword.getCompoundDrawables()[2] == null) { return false; } if (event.getAction() != MotionEvent.ACTION_UP) { return false; } if (event.getX() > edtPassword.getWidth() - edtPassword.getPaddingRight() - showpass_icon.getIntrinsicWidth()) { if (isPasswordVisible) { runOnUiThread(new Runnable() { @Oviewride public void run() { //edtPassword.setError(null); edtPassword.setTransformationMethod( PasswordTransformationMethod.getInstance()); edtPassword.setSelection(edtPassword.getText().length()); showpass_icon.setBounds(0, 0, showpass_icon.getIntrinsicWidth(), showpass_icon.getIntrinsicHeight()); edtPassword.setCompoundDrawables(pass_drawable, null, showpass_icon, null); } }); isPasswordVisible = false; } else { runOnUiThread(new Runnable() { @Oviewride public void run() { //edtPassword.setError(null); edtPassword.setTransformationMethod( HideReturnsTransformationMethod.getInstance()); edtPassword.setSelection(edtPassword.getText().length()); hidepass_icon.setBounds(0, 0, hidepass_icon.getIntrinsicWidth(), hidepass_icon.getIntrinsicHeight()); edtPassword.setCompoundDrawables(pass_drawable, null, hidepass_icon, null); } }); isPasswordVisible = true; } } return false; } }); } retornair falso; private void setPasswordDrawable() { final Drawable showpass_icon = getResources().getDrawable(R.mipmap.ic_action_password_visibility); final Drawable hidepass_icon = getResources().getDrawable(R.mipmap.ic_action_password_visibility_off); final Drawable pass_drawable = getResources().getDrawable(R.mipmap.ic_action_password); pass_drawable.setBounds(0, 0, pass_drawable.getIntrinsicWidth(), pass_drawable.getIntrinsicHeight()); //edtPassword.setCompoundDrawables(pass_drawable, null, showpass_icon, null); edtPassword.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { if (edtPassword.getCompoundDrawables()[2] == null) { return false; } if (event.getAction() != MotionEvent.ACTION_UP) { return false; } if (event.getX() > edtPassword.getWidth() - edtPassword.getPaddingRight() - showpass_icon.getIntrinsicWidth()) { if (isPasswordVisible) { runOnUiThread(new Runnable() { @Oviewride public void run() { //edtPassword.setError(null); edtPassword.setTransformationMethod( PasswordTransformationMethod.getInstance()); edtPassword.setSelection(edtPassword.getText().length()); showpass_icon.setBounds(0, 0, showpass_icon.getIntrinsicWidth(), showpass_icon.getIntrinsicHeight()); edtPassword.setCompoundDrawables(pass_drawable, null, showpass_icon, null); } }); isPasswordVisible = false; } else { runOnUiThread(new Runnable() { @Oviewride public void run() { //edtPassword.setError(null); edtPassword.setTransformationMethod( HideReturnsTransformationMethod.getInstance()); edtPassword.setSelection(edtPassword.getText().length()); hidepass_icon.setBounds(0, 0, hidepass_icon.getIntrinsicWidth(), hidepass_icon.getIntrinsicHeight()); edtPassword.setCompoundDrawables(pass_drawable, null, hidepass_icon, null); } }); isPasswordVisible = true; } } return false; } }); } } private void setPasswordDrawable() { final Drawable showpass_icon = getResources().getDrawable(R.mipmap.ic_action_password_visibility); final Drawable hidepass_icon = getResources().getDrawable(R.mipmap.ic_action_password_visibility_off); final Drawable pass_drawable = getResources().getDrawable(R.mipmap.ic_action_password); pass_drawable.setBounds(0, 0, pass_drawable.getIntrinsicWidth(), pass_drawable.getIntrinsicHeight()); //edtPassword.setCompoundDrawables(pass_drawable, null, showpass_icon, null); edtPassword.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { if (edtPassword.getCompoundDrawables()[2] == null) { return false; } if (event.getAction() != MotionEvent.ACTION_UP) { return false; } if (event.getX() > edtPassword.getWidth() - edtPassword.getPaddingRight() - showpass_icon.getIntrinsicWidth()) { if (isPasswordVisible) { runOnUiThread(new Runnable() { @Oviewride public void run() { //edtPassword.setError(null); edtPassword.setTransformationMethod( PasswordTransformationMethod.getInstance()); edtPassword.setSelection(edtPassword.getText().length()); showpass_icon.setBounds(0, 0, showpass_icon.getIntrinsicWidth(), showpass_icon.getIntrinsicHeight()); edtPassword.setCompoundDrawables(pass_drawable, null, showpass_icon, null); } }); isPasswordVisible = false; } else { runOnUiThread(new Runnable() { @Oviewride public void run() { //edtPassword.setError(null); edtPassword.setTransformationMethod( HideReturnsTransformationMethod.getInstance()); edtPassword.setSelection(edtPassword.getText().length()); hidepass_icon.setBounds(0, 0, hidepass_icon.getIntrinsicWidth(), hidepass_icon.getIntrinsicHeight()); edtPassword.setCompoundDrawables(pass_drawable, null, hidepass_icon, null); } }); isPasswordVisible = true; } } return false; } }); } }); private void setPasswordDrawable() { final Drawable showpass_icon = getResources().getDrawable(R.mipmap.ic_action_password_visibility); final Drawable hidepass_icon = getResources().getDrawable(R.mipmap.ic_action_password_visibility_off); final Drawable pass_drawable = getResources().getDrawable(R.mipmap.ic_action_password); pass_drawable.setBounds(0, 0, pass_drawable.getIntrinsicWidth(), pass_drawable.getIntrinsicHeight()); //edtPassword.setCompoundDrawables(pass_drawable, null, showpass_icon, null); edtPassword.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { if (edtPassword.getCompoundDrawables()[2] == null) { return false; } if (event.getAction() != MotionEvent.ACTION_UP) { return false; } if (event.getX() > edtPassword.getWidth() - edtPassword.getPaddingRight() - showpass_icon.getIntrinsicWidth()) { if (isPasswordVisible) { runOnUiThread(new Runnable() { @Oviewride public void run() { //edtPassword.setError(null); edtPassword.setTransformationMethod( PasswordTransformationMethod.getInstance()); edtPassword.setSelection(edtPassword.getText().length()); showpass_icon.setBounds(0, 0, showpass_icon.getIntrinsicWidth(), showpass_icon.getIntrinsicHeight()); edtPassword.setCompoundDrawables(pass_drawable, null, showpass_icon, null); } }); isPasswordVisible = false; } else { runOnUiThread(new Runnable() { @Oviewride public void run() { //edtPassword.setError(null); edtPassword.setTransformationMethod( HideReturnsTransformationMethod.getInstance()); edtPassword.setSelection(edtPassword.getText().length()); hidepass_icon.setBounds(0, 0, hidepass_icon.getIntrinsicWidth(), hidepass_icon.getIntrinsicHeight()); edtPassword.setCompoundDrawables(pass_drawable, null, hidepass_icon, null); } }); isPasswordVisible = true; } } return false; } }); } 

    Paira configurair o erro

     public void setViewError(View view, String message) { if (view instanceof EditText) { ((EditText) view).setError(message); } } { public void setViewError(View view, String message) { if (view instanceof EditText) { ((EditText) view).setError(message); } } } public void setViewError(View view, String message) { if (view instanceof EditText) { ((EditText) view).setError(message); } } 

    exemplo ao vivo

  • EditText em ListView com windowSoftInputMode adjustPan
  • Vista EditText girada personalizada com seleção de trabalho, localization do cursor, etc.
  • One Solution collect form web for “Texto desenhável na edição de text não atualizando após erro”

    Você pode usair isso como –

     if(error=true){ editText.setCompoundDrawablesWithIntrinsicBounds( 0, 0,R.drawable.ic_error, 0); editText.setCompoundDrawablePadding(5);} else{ editText.setCompoundDrawablesWithIntrinsicBounds( 0, 0,R.drawable.ic_corrct, 0); editText.setCompoundDrawablePadding(5);} 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.