I need to know the current color of the button, the color changes randomly, and I need to know its color, what procedures allow it? I ask you not to kick hard, if anything, I'm just a beginner
Can't you simply take note of the new color when it changes? Randomly or not, you have an assignment statement there to make it happen, right?
It's at all possible that I missed you point, but the above looks somewhat logical so i posted it anyway.
BTW, why did you post yor question in this forum's section?
Can't you simply take note of the new color when it changes? Randomly or not, you have an assignment statement there to make it happen, right?
It's at all possible that I missed you point, but the above looks somehwta logical so i posted it anyway.
BTW, why did you post yor question in this forum's section?
Sorry, I didn't explain myself well.
When I said " Can't you simply take note " I referred to the possibility to store the newly assigned value in a global variable (or in the Tag property of the button) not to jot it down on paper after reading a log statement.
You could even store in Tag an history of last used colors, if you need it.
Moving thread: you can't. Eventually @Erel will do it.
Sorry, I didn't explain myself well.
When I said " Can't you simply take note " I referred to the possibility to store the newly assigned value in a global variable (or in the Tag property of the button) not to jot it down on paper after reading a log statement.
You could even store in Tag an history of last used colors, if you need it.
Moving thread: you can't. Eventually @Erel will do it.
Maybe this will shed some light on a possible solution ...
B4X:
Private MyTimer As Timer 'process global
Private xui As XUI
Private btnMyButton As B4XView
Private pnlMyPanel As B4XView
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("test")
MyTimer.Initialize("MyTimer", 5000)
MyTimer.Enabled = True
'.......................................................
Sub MyTimer_Tick
Dim MyColor As Int = xui.Color_ARGB(255,Rnd(1,255),Rnd(1,255),Rnd(1,255))
btnMyButton.Color = MyColor
btnMyButton.Tag = MyColor '@@@ Store the current color in the Button.Tag property ... OR store it in a Global Variable !
End Sub
Private Sub btnMyButton_Click 'recolor the panel , same as button
pnlMyPanel.Color = btnMyButton.tag
End Sub
PS: if you are slightly confused with re XUI / B4XViews then just make the following changes ...
B4X:
Private btnMyButton As Button
Private pnlMyPanel As Panel
Sub MyTimer_Tick
Dim MyColor As Int = Colors.ARGB(255,Rnd(1,255),Rnd(1,255),Rnd(1,255))
'............... more
As a follow up ,should you need the Hex color value ...
B4X:
Log(ColorToHex(MyColor))
Private Sub ColorToHex(clr As Int) As String
Dim bc As ByteConverter
Return bc.HexFromBytes(bc.IntsToBytes(Array As Int(clr)))
End Sub
Converts hex color strings to a color int value and vice versa: Private Sub ColorToHex(clr As Int) As String Dim bc As ByteConverter Return bc.HexFromBytes(bc.IntsToBytes(Array As Int(clr))) End Sub Private Sub HexToColor(Hex As String) As Int Dim bc As ByteConverter If...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.