Mario Duarte
Mario Duarte

Reputation: 192

Binding a byte[] to ImageView on Android using MvvmCross

I'm trying to binding an ImageView to byte[].

<ImageView
    android:layout_height="match_parent"
    android:layout_width="match_parent"
    android:layout_weight="1"
    local:MvxBind="Bitmap CaptchaImage, Converter=InMemoryImage"
    android:id="@+id/imageView1" />

I'm using the tutorial from Picture Taking as a guide: https://github.com/MvvmCross/MvvmCross-Tutorials/tree/master/PictureTaking

But the image isn't showing. What could possibly be wrong?

Upvotes: 1

Views: 726

Answers (2)

Mario Duarte
Mario Duarte

Reputation: 192

The file "PictureChooserPluginBootstrap.cs" was in my Bootstrap folder but somehow wasn't in my project. All I needed was to "Include in Project" option.

Upvotes: 1

We&#39;re All Mad Here
We&#39;re All Mad Here

Reputation: 1554

Instead of struggling with the xml you can just use this code in your java class:

public static void setImageViewWithByteArray(ImageView view, byte[] data) {
        Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);
        view.setImageBitmap(bitmap);
    }

Please test it and tell me if it works.

Upvotes: 0

Related Questions