Android Question Problem trasform list to bytes

IVR

Member
Licensed User
Hi! I have a problem, when I trasform a list into an array bytes.
If a list item is > 256 i get a negative number. Code sample.
Thank you
B4X:
   Dim LConfig as list
    LConfig.Initialize
    LConfig.Add(1)
    LConfig.Add(20)
    LConfig.Add(10)
    LConfig.Add(50)
    LConfig.Add(100)
    LConfig.Add(40)
    LConfig.Add(80)
    LConfig.Add(300)

Dim p() As Byte = ListToBytes(confList)
Sub ListToBytes(list As List) As Byte()

    Dim b(list.Size) As Byte
    For i = 0 To list.Size - 1
        b(i) = list.Get(i)
        Log(b(i))
    Next
    Return b
End Sub
 

DonManfred

Expert
Licensed User
Longtime User
Upvote 0
Top