Actually, to change just the error message color, you can set textColorError in your theme ( and also set colorControlNormal and. You are responsible for setting/ clearing the error. This way it refreshes the error message before setting a new one. I suggest using Textwatcher fucntion in Android for more efficient validation handling. I have two EditText and i set error when the edit text is empty, but the problem is when the EditText take value, the error still show, like this: enter image description here. This is my code : String username= edit_ text_ username. equalsIgnoreCase( " " ) ) { editText. setError( " This field can not be blank" ) ; }. So to do the both thing on your own, User this code. When any view get focus, you are setting no error and when focus changed, you check whether there is valid input or not like below. Setting a custom color. By default the line of the EditText will be red.
If you need to display a different color you can use the following code as soon as you call setError. getBackground( ). setColorFilter( getResources( ). In your else bracket, put playerName. setError( null), which will clear the error. EditText myEdit = ( EditText) findViewById( R. my_ edit) ; if ( TextUtils. toString( ) ) ) { / / set the warning myEdit. requestFocus( ) ; / / show error icon myEdit. setCompoundDrawablesWithIntrinsicBounds( 0, 0. I need to give style to errorText which appears after setting setError in EditText.
private fun setErrorOnSearchView( searchView: SearchView, errorMessage: String) { val id = searchView. public class MyEditText extends EditText { public MyEditText( Context context, AttributeSet attrs). To get only the error- icon without an error- message- popup only when setError( " " ) is called ( i. set an empty String as.