iOS Question Query for Gradient

Nitin Joshi

Active Member
Licensed User
Longtime User
I have used B4A code in B4i for gradient feature however error message is popped as below...

B4XMainPage - 244: Unknown type: gradientdrawable Are you missing a library reference?

Code: Copy
Dim cd As GradientDrawable
 
Thanks Erel.
I want to use sub (not designer) in B4Xpage because my program decides button color based on some conditions.
What is your suggestion? Shall i create a common sub for B4A and B4i? in that case, i need to modify B4A codes...
 
Upvote 0
 
Upvote 0
Dear Erel, I tried to apply GradientMaker library. I have a question. will it work for dynamically generated controls? My APP gets hang when i apply gradientmaker.
I am applying it to B4A APP.

My project includes UDP programming...

Here ports() is array of buttons...

Code: Copy
    Dim cd As GradientMaker
    Dim clrs(2) As Int
    clrs(1)=Colors.White
    For i=firstTag To lastTag
        If i>=tG1 And i<=tG2 Then
            Select Case getStatus
                Case 0
                    clrs(0)=Colors.Red
                    cd.Initialize
                    cd.SetGradient(ports(i),"LEFT_RIGHT",clrs)
                Case 1
                    clrs(0)=Colors.RGB(0,128,0)
                    cd.Initialize
                    cd.SetGradient(ports(i),"LEFT_RIGHT",clrs)
                Case 2
                    clrs(0)=Colors.Gray
                    cd.Initialize
                    cd.SetGradient(ports(i),"LEFT_RIGHT",clrs)
            End Select
            
        End If
    Next
 
Upvote 0
Hi All, I have added supporting attachments for further explanation. Attachment includes two videos and error message. Codes as below..

Background: I changed GradientDrawable to GradientMaker to support B4A and B4i. Button are dynamically generated..

Problem: APP works perfectly when i use GradientDrawable however when i change to GradientMaker APP hangs and stops UDP communication.

Code: Copy
Private Sub Set_Control_Status(firstTag As Int, lastTag As Int, getStatus As Int)
    Dim cd As GradientDrawable
    Dim clrs(2) As Int
    clrs(1)=Colors.White
    For i=firstTag To lastTag
        If i>=tG1 And i<=tG2 Then
            Select Case getStatus
                Case 0
                    clrs(0)=Colors.Red
                    cd.Initialize("LEFT_RIGHT",clrs)
                    cd.CornerRadius=10dip
                    ports(i).background = cd
                Case 1
                    clrs(0)=Colors.RGB(0,128,0)
                    cd.Initialize("LEFT_RIGHT",clrs)
                    cd.CornerRadius=10dip
                    ports(i).background = cd
                Case 2
                    clrs(0)=Colors.Gray
                    cd.Initialize("LEFT_RIGHT",clrs)
                    cd.CornerRadius=10dip
                    ports(i).background = cd
            End Select
          
        End If
    Next
End Sub

Code: Copy
Private Sub Set_Control_Status(firstTag As Int, lastTag As Int, getStatus As Int)
    Dim cd As GradientMaker
    Dim clrs(2) As Int
    clrs(1)=Colors.White
    For i=firstTag To lastTag
        If i>=tG1 And i<=tG2 Then
            Select Case getStatus
                Case 0
                    clrs(0)=Colors.Red
                    cd.Initialize
                    cd.SetGradient(ports(i),"LEFT_RIGHT",clrs)
                Case 1
                    clrs(0)=Colors.RGB(0,128,0)
                    cd.Initialize
                    cd.SetGradient(ports(i),"LEFT_RIGHT",clrs)
                Case 2
                    clrs(0)=Colors.Gray
                    cd.Initialize
                    cd.SetGradient(ports(i),"LEFT_RIGHT",clrs)
            End Select
          
        End If
    Next
End Sub

Code: Copy
Private Sub btn_Click()

    Dim btn As Button=Sender

    UDP_Sent("SHCSPV" & NumberFormat(btn.Tag,3,0),deviceIP)

End Sub
 

Attachments

Last edited:
Upvote 0
There is no project we could test !
If it is a B4XPages project click on this line on the top of the B4XMainPage module.
B4X: Copy
'Ctrl + click to export as zip: ide://run?File=%B4X%\Zipper.jar&Args=CameraIntent.zip
This will produce a zip file of your project. The end of this line may look a bit different in your project.
 
Upvote 0
Project is complex because it communicates with hardware. I believe that even if i export, can not be tested as it needs hardware.

Still, i can make seperate small project with relevant codes... Will it be helpful?

Meanwhile, error code line is end of UDP packet arrived...
 
Upvote 0
Also, hardware broadcasts packet at regular interval. Btn background (red or green) changes based on arrived packet.

When btn is clicked, udp sent packet to hardware and upon arrived packet from hardwarebbtn backround is changed.

Please see videos also. Let me repeat buttons are generated dynamically.
 
Upvote 0
Will it be helpful?
Sure, this is what we, at least i, need.
The best way to help is to have all the code producing the error in a project.
That way we can test it in exactly the same conditions as you and see what happens.
 
Upvote 0
Something is weird...If i use debug option then there is an issue. If i release (install on mobile) then it works fine.
 
Upvote 0
Back
Top