In my project I have to verify if a backround is equal to another for an edit text (the edit text has a custom drawable). I have tried this code but it’s not working:
if (editText.getBackground().equals(getResources().getDrawable(R.drawable.edit_text_box_red)))
{
editText.setBackgroundResource(R.drawable.edit_text_box_white);
}
I need this, because when I press a button and my editText background is red I have to make it white, to it’s previous state. How can I do this?
I think it would make sense to store the background information when you change the background in the first place. One way to do this would be
setTag(). For example, when you change the view’s background to red, you also performeditText.setTag("red"). Then later, you can do