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:
Dim cd As GradientDrawable
 

Nitin Joshi

Active Member
Licensed User
Longtime User
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

Erel

B4X founder
Staff member
Licensed User
Longtime User
 
Upvote 0

Nitin Joshi

Active Member
Licensed User
Longtime User
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...

GradientMaker Sub:
    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

Nitin Joshi

Active Member
Licensed User
Longtime User
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.

Gradient Drawable:
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

GradientMaker Code:
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

UDP Packet when Button click:
Private Sub btn_Click()

    Dim btn As Button=Sender

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

End Sub
 

Attachments

  • Error Message.rar
    11.8 KB · Views: 80
  • GradientMaker.rar
    60.2 KB · Views: 74
  • GradientDrawable.rar
    243.1 KB · Views: 71
Last edited:
Upvote 0

klaus

Expert
Licensed User
Longtime User
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:
'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

Nitin Joshi

Active Member
Licensed User
Longtime User
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

Nitin Joshi

Active Member
Licensed User
Longtime User
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

klaus

Expert
Licensed User
Longtime User
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

Nitin Joshi

Active Member
Licensed User
Longtime User
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
Top