Is it possible to do this? I'm reading an XML file that has the Base64 string of an image. I'm planning to use Base64.decode to have the byte array of the image string. I'm stuck though on how to use it in an ImageView. Do i have to create a 'drawable' class first then set it to ImageView's src property?
Thanks!
In case anyone else stumbles across this question, here is the code
import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.widget.ImageView; public class ModelAssistant { public static void setImageViewWithByteArray(ImageView view, byte[] data) { Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length); view.setImageBitmap(bitmap); } }
You can use BitmapFactory.decodeByteArray() to perform the decoding.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With