Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Remove Background Color of Button to get Default Background in Android

I am Working on a Test Application in which every question is presented with Four options [those options are via Button]. When a User clicks a button and his answer is correct then background of that button Turns Green, and if his answer is incorrect it turns Red. What i want to do is Reset the Button Background on Next Question.

After Searching a lot of People have asked the same Question and Accepted the answer as

  btnChoiceB.setBackgroundColor(0x00000000);

But the problem is, it turns the Whole Button Transparent, which is not my requirement. I Just want the default color Back.

Do Not Suggest

btnChoiceB.setBackgroundColor(null);

as it does not work.

This is What i want Back. This is What i want Back.

UPDATE/ANSWERED

As Suggested by quick learner,

btnChoiceB.setBackgroundResource(android.R.drawable.btn_default);

worked pretty cleanly.

like image 837
Adnan Ahmad Khan Avatar asked Oct 22 '25 14:10

Adnan Ahmad Khan


1 Answers

Try this

btnChoiceB.setBackgroundResource(android.R.drawable.btn_default);
like image 93
Quick learner Avatar answered Oct 24 '25 04:10

Quick learner



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!