Android Question SwiftButton color during runtime

lucasheer

Active Member
Licensed User
Longtime User
Is it possible to change the color of the Swift Button control during runtime?



The custom properties I want to change are:

Primary Color
Secondary Color

How would I go about doing this? And will the view need to be invalidated?

Thank you!
 

lucasheer

Active Member
Licensed User
Longtime User
Sorry! I didn't realize that the SwiftButton has a function:

SetColors(Primary as int, Secondary as int)

I've been focusing on B4XLoadingIndicator, which does not have such function.

Does anyone know how to change the color on B4XLoadingIndicator?
 
Upvote 0

lucasheer

Active Member
Licensed User
Longtime User
Figured it out!

Just grabbed a copy of the original class, and edited the clr variable to be public:

B4X:
    Public clr As Int

myLoadingIndicator.clr = Starter.primarycolor
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Just grabbed a copy of the original class, and edited the clr variable to be public:
This is a mistake unless there is no other option.

Is it possible to change the color of the Swift Button control during runtime?
Yes. Call SwiftButton1.SetColors.

Make sure to use the latest version of XUI Views.
 
Upvote 0

lucasheer

Active Member
Licensed User
Longtime User
This is a mistake unless there is no other option.


Yes. Call SwiftButton1.SetColors.

Make sure to use the latest version of XUI Views.

I needed to change the color of B4XLoadingIndictor. There's no method in the original class to change the color :(
 
Upvote 0

lucasheer

Active Member
Licensed User
Longtime User
Sorry, I only read the first post (which is where the question should be)...

I deleted my custom B4XLoadingIndicator class, and am calling DesignerCreatedView on the default B4XLoadingIndicator.

B4X:
Dim mp As Map
    mp.Initialize
    mp.Put("Color", Starter.primaryColor)
    mp.Put("IndicatorStyle", "Three Circles 2")
    mp.Put("Duration", 1000)
    myLoadingIndicator.DesignerCreateView(myLoadingIndicator.mBase, Null, mp)


Worked Perfectly 👍 👍 👍

Thank you.
 
Upvote 0
Top