This is because view.setBackgroundColor(int) expects the color resource to not be an "actual" integer value. Try declaring it in your .xml color, see this . However, I'm not quite sure what you mean by deleting the background. If you want it to have the original value, I suggest you save the source file with the ability to draw (using getBackground() ). Otherwise, you are likely to lose formatting, since most of the default backgrounds in Android are Drawable (selector), not plain colors.
dmon
source share