[Solved] How to change button background button in another activity?


To change the background of a button, first you must have the button initialized. Lets say you initialize the button as such:

Button myButton = (Button) findViewById(R.id.theButton);

Of course, the ID of your button is whatever you set it as in the XML file. You can change the background color whenever you want in the same scope as your declaration of the button as such:

myButton.setBackgroundColor(R.color.anyColor);

Hopefully this answers your question as it’s quite confusing.

solved How to change button background button in another activity?