B4J Question [Solved]The problem is about ' xui.PaintOrColorToColor(myColor) ' Vs ' FX.Colors.From32Bit(myColor) '

Theera

Expert
Licensed User
Longtime User
I'm sorry that I don't know to set the title of this thread better.
I have 2 codes in the same B4XCustomView. The codes are different to solve each together.
My work is finish,but I can't expain myself , I didn't understand my stratgies to be resolved them.

B4X:
Private Sub CreateLabel(Text As String, Size As Int, myColor As Int, Alignment As String) As B4XView
    Dim lbl As Label
    lbl.Initialize("")
    lbl.Text = Text
  
    #If B4A
    lbl.TextColor = myColor
    lbl.TextSize = Size
    If Alignment = "CENTER" Then
        lbl.Gravity = Gravity.CENTER
    Else If Alignment = "RIGHT" Then
        lbl.Gravity = Gravity.CENTER_VERTICAL + Gravity.RIGHT
    End If
    #Else If B4J
        'Can't be used
        'lbl.TextColor =xui.PaintOrColorToColor(myColor)   '<== the problem why can't be code this line but can code the next line
        lbl.TextColor = FX.Colors.From32Bit(myColor)
        lbl.Font=xui.CreateDefaultFont(Size)
   
        If Alignment = "CENTER" Then
            lbl.Alignment = "CENTER"
        Else If Alignment = "RIGHT" Then
            lbl.Alignment = "CENTER_RIGHT"
        End If
    #Else If B4i
        lbl.TextColor = Colors.From32Bit(myColor)
        lbl.Font = Font.CreateNew(Size)
        If Alignment = "CENTER" Then
            lbl.TextAlignment = lbl.ALIGNMENT_CENTER
        Else If Alignment = "RIGHT" Then
            lbl.TextAlignment = lbl.ALIGNMENT_RIGHT
        End If
    #End If
  
    Return lbl
End Sub

B4X:
Public Sub setDisplayTextColor(myColor As Int)
    mDisplayTextColor = myColor
    If lblDisplay.IsInitialized Then
        #If B4A
            lblDisplay.TextColor = myColor
        #Else If B4J
            'Can't be used
            'lblDisplay.TextColor = FX.Colors.From32Bit(myColor)   '<== the problem why can't be code this line but can code the next line
            lblDisplay.TextColor =xui.PaintOrColorToColor(myColor)
       
        #Else If B4i
            'lblDisplay.TextColor = Colors.From32Bit(myColor)
             lblDisplay.TextColor =xui.PaintOrColorToColor(myColor)
        #End If
    End If
End Sub
 
Solution
Let me explain it for you.
The lbl is as label, it only works on B4J,you must use FX.Colors.
and lblDisplay is as b4xview, which is cross-platform, you should use xui.PaintOrColorToColor

teddybear

Well-Known Member
Licensed User
Let me explain it for you.
The lbl is as label, it only works on B4J,you must use FX.Colors.
and lblDisplay is as b4xview, which is cross-platform, you should use xui.PaintOrColorToColor
 
Upvote 0
Solution

Theera

Expert
Licensed User
Longtime User
Let me explain it for you.
The lbl is as label, it only works on B4J,you must use FX.Colors.
and lblDisplay is as b4xview, which is cross-platform, you should use xui.PaintOrColorToColor
Thank you for teaching .
 
Upvote 0
Top