I have very strange problem in Android 5. If user inputs something wrong I want to set error to edittext and change it color to red, and when user starts typing something I want to change color back to green. This is how i do it:
eText.setError(message);
eText.getBackground().setColorFilter(Color.RED, PorterDuff.Mode.SRC_ATOP);
eText.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before,
int count) {
eText.getBackground().setColorFilter(
ctx.getResources().getColor(R.color.dark_green), PorterDuff.Mode.SRC_ATOP);
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {}
@Override
public void afterTextChanged(Editable s) {}
});
In lower android versions than 5, everything works perfect, but not in Lollipop. If I change one edittext color, all edittexts in all app changes it color. Is there any way to fix this strange thing? Or it is some of material design and Android 5 tricks which I don't know?