How to change a button color back to DefaultDrawable after using another color.

webjefe

Member
Licensed User
Longtime User
How do I change a button color back to DefaultDrawable after using another color momentarily?
I have a button that I set in the Designer as DefaultDrawable which, of course, sets my button color to the default, which I don't know what it is. Then I programatically change it to Red or Green.

Since Button.Color is write-only, I can't save it and change it back to it.

I need to change it back to the original color.
 

Mahares

Expert
Licensed User
Longtime User
Here a way to do it by storing the original color in the tag:
B4X:
Dim B1 as Button
B1.Tag=B1.Background  'Store original color in tag in activity_Create
B1.Color=Colors.Red    'Change button color to red


Sub B1_Click     'Return button color to original before it was changed to red 
  B1.Background=B1.Tag
End Sub
 
Upvote 0
Top