I have got this error on Android Studio IDE. It says
Incompatible types; Required android.widget.EditText and Found java.lang.String
@Override
public void afterTextChanged(Editable s) {
if (editabletext.length() == 8) {
editabletext = editabletext.getText().toString().replaceAll("([0-9]{4})([0-9]{4})", "$1-$2")
}
}
editabletext
is an EditText andreplaceAll
returns a String. What the compiler says is that you can't assign aString
to anEditText
. You could change your code this way:Replace
with
as
editabletext
is of typeEditable
andreplaceAll
returns aString
find the definition of "editabletext" and change the type from EditText to String