Douwe Siegersma Member Licensed User Longtime User Mar 13, 2022 #1 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?
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 Mar 13, 2022 #2 B4X: Copy 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
B4X: Copy 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.
Douwe Siegersma Member Licensed User Longtime User Mar 13, 2022 #3 Thank you Agraham. I will try this. And I use the initialize2 method for most of the objects. Upvote 0
Erel B4X founder Staff member Licensed User Longtime User Mar 13, 2022 #4 Tip: use B4XView.SetColorAndBorder instead. Simpler and cross platform. Upvote 0
Douwe Siegersma Member Licensed User Longtime User Mar 13, 2022 #5 Ok, Thank you Erel. Still learning (a lot) Upvote 0