Android Question Save background (ColorDrawable)

Douwe Siegersma

Member
Licensed User
Hello,

I want to save the properties of an object (stored in a list) in a file.
This goes well but when loading them again setting the background property gives an error.
Java expects a ColorDrawable but gets a string. Is there a way to convert the string to a ColorDrawable again?
 

agraham

Expert
Licensed User
Longtime User
B4X:
Dim cd As ColorDrawable
cd.Initialize(color, radius)
color and radius are Ints. Also look at the Initialize2 method for ColorDrawable. If the color string is in hex form you can use ByteConverter.HexToBytes then ByteConverter.IntsFromBytes to get an Int color.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…