Android Question Convert hex to 32bit int

pauleffect

Member
Licensed User
Longtime User
B4X:
    Dim bc As ByteConverter (color as string)

   Dim bytes() As Byte = bc.HexToBytes("0xff"&color)
   colorInt = bc.IntsFromBytes(bytes)(0)
    Log(colorInt)

It's supposed to output 4280910009. It outputs 570369966...
Help pls :)
 

pauleffect

Member
Licensed User
Longtime User
Sorry, erel, i'm at work, don't kniw exactly.
But to summarize, i need to take a string hex code such as "8e44ad" and convert that to an int value.

B4X:
Dim i as int = 0xff8e44ad
WhateverPanel.Color=i
This works just fine.

But when i try to convert any color from hex *string* to int, i get an int value other than it's ARGB correspondent.
I am clearly doing something (hilariously) wrong.
 
Upvote 0

pauleffect

Member
Licensed User
Longtime User
Thank you kindly.
Btw, i upgraded from v5 to v7 recently.
Love what you've done with it.
Congratulations.
 
Upvote 0
Top