I am working on an Android application.In my app I have to use images based on the text.So I write OnChangeListener()
for EditText
.The following is
One more solution can be to use boolean variable, so that it doesn't get into infinite callstack and eventually giving stackoverflow exception
public void afterTextChanged(Editable s) {
if(!flag)
{
flag = true;
edt.setText("string");
flag = false;
}
}
Just simply remove your listener before you set the text, and register it again after you are done, like described here:
Clear EditText text after adding onTextChanged implemenation