Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Problem solved after a lot of research and permutations- (Also thanks to @van)</p> <p>Create a new class that will extend <code>EditText</code> something like this-</p> <pre><code>public class MyEditText extends EditText { public MyEditText(Context context, AttributeSet attrs) { super(context, attrs); } @Override public void setError(CharSequence error, Drawable icon) { setCompoundDrawables(null, null, icon, null); } } </code></pre> <p>Use this class as a view in your xml like this-</p> <pre><code>&lt;com.raj.poc.MyEditText android:id="@+id/et_test" android:layout_width="fill_parent" android:layout_height="wrap_content"/&gt; </code></pre> <p>Now in the third step, just set a <code>TextWatcher</code> to your custom text view like this-</p> <pre><code> et = (MyEditText) findViewById(R.id.et_test); errorIcon = getResources().getDrawable(R.drawable.ic_error); errorIcon.setBounds(new Rect(0, 0, errorIcon.getIntrinsicWidth(), errorIcon.getIntrinsicHeight())); et.setError(null,errorIcon); et.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // TODO Auto-generated method stub } @Override public void afterTextChanged(Editable s) { if(s.toString().length()&gt;6){ et.setError("", null); }else{ et.setError("", errorIcon); } } }); </code></pre> <p>where <code>R.drawable.ic_error</code> = <img src="https://i.stack.imgur.com/1luXA.png" /></p> <p>Keeping text null solves the problem But if we keep only null in setError(null), this won't show the validation error; it should be null along with second param.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload