0

I have two buttons in a table row. Both buttons are set to MatchParent for height and the table row's height is set by weight. I have it so when the button is clicked the background changes from the default to a red that gradually turns green until the button can be used again, then the button returns to the default background.

Everything works fine unless both buttons are clicked. They seem to lose some of the height and everything has to resize to fit until they are back to the default.

I saw this https://stackoverflow.com/a/1726352/1272209

which explained a lot to me, but I can not figure out how to set this as the background in the code, right now to get it back to default, I have

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

But I do not understand how to access the custom_button from the code. I am very new to .xml files in android.

Thank you,

Community
  • 1
  • 1
RustyH
  • 473
  • 7
  • 22

1 Answers1

1

You need to reference your drawable xml file. Make sure it is saved in the res/drawable folder, then reference is by calling R.drawable.custom_button (remove the android prefix).

Lbut.setBackgroundResource(R.drawable.custom_button)

Chris Feist
  • 1,678
  • 15
  • 17