Android Question how to set a drawable when panel is clicked.

shashkiranr

Active Member
Licensed User
Longtime User
Hi,

I want the user to know when he has clicked an panel by changing the background of the panel. initially the panel is white. when the user clicks need to make it light gray and then back to white again when the user releases his finger.

Kindly let me know your suggestion.

Regards,
SK
 

Pendrush

Well-Known Member
Licensed User
Longtime User
Panel example:

B4X:
Dim pnlPanel As Panel
pnlPanel.Initialize("")

Dim ClickColor As ColorDrawable
Dim NormalColor As ColorDrawable
ClickColor.Initialize(Colors.Red, 0dip)
NormalColor.Initialize(Colors.Blue, 0dip)

Dim sld As StateListDrawable
sld.Initialize
sld.AddState(sld.State_Pressed, ClickColor)
sld.AddCatchAllState(NormalColor)
pnlPanel.Background = sld

Tutorial:
http://www.b4x.com/android/forum/threads/statelistdrawable-example.6589/
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…