I am creating a MCQ application in which there are four option Buttons
.Initially all the buttons's color is default color.Whenever user clicks on correct answer background color of the Button
changes to green and when user clicks on wrong option Background color of the Button
changes to red and display correct answer Button
in green. After that user clicks on next question button. Now I want to change the background color of all the optionButtons
to its initial state i.e default color. I don't know how to do it. Please help me in changing the Button image to its default color/image.
Asked
Active
Viewed 970 times
1

Nishant
- 32,082
- 5
- 39
- 53
1 Answers
0
Inside the onClick() of the NEXT BUTTON place a the code to change the option button colors to the colors of your choice.
onClick()
{
button.setBackgroundColor(color);
}
The default color is not a color, it is StateListDrawable of many 9-patch images I suggest you set the background of buttons to be white for option buttons and then set it back to white when NEXT button is pressed.

jaisonDavis
- 1,407
- 2
- 22
- 36
-
can you help me in getting the default color id of the button – Nishant May 27 '12 at 00:21
-
The background of a button is not a color its a StateListDrawable of many 9-patch images – jaisonDavis May 27 '12 at 03:22
-
1http://stackoverflow.com/questions/2401009/how-to-gradient-fill-a-buttons-background – jaisonDavis May 27 '12 at 03:31
-
http://stackoverflow.com/questions/1521640/standard-android-button-with-a-different-color – jaisonDavis May 27 '12 at 03:39
-
Thanks, I don't have much idea about using 9-patch images.But those links were helpful I will try. – Nishant May 27 '12 at 11:30