I agree with @njzk2 comments re:InputFilter, if the recursion is the trouble you want to solve, you can try something like this to prevent it:
// make your TextWatcher a class variableprotected TextWatcher mTextWatcher = new TextWatcher() { public void afterTextChanged(Editable s) { textFixerUpper(search_name, s.toString()); } public void beforeTextChanged(CharSequence s, int start, int count, int after){} public void onTextChanged(CharSequence s, int start, int before, int count){} };protected textFixerUpper(EditText t, String s){ t.removeTextChangedListener(mTextWatcher); // remove the listener t.setText(s.replace("something", "s**ething")); // update the text t.addTextChangedListener(mTextWatcher); // add the listener back}or by setting a Boolean flag instead of removing and re-adding the listener....though either seems a bit messy.
ليست هناك تعليقات:
إرسال تعليق