I\'m trying to bind an image\'s src.
I have tried using MvxHttpImageView like this
I built a converter, which converts a drawable name to a Bitmap and bound the Bitmap to the ImageView.
The converter:
public class ImageNameToBitmapConverter : MvxValueConverter
{
protected override Bitmap Convert(string value, Type targetType, object parameter, CultureInfo culture)
{
var topActivity = Mvx.Resolve();
var bm = BitmapFactory.DecodeResource(topActivity.Activity.Resources, GetResourceId(value, "drawable", topActivity));
return bm;
}
private static int GetResourceId(string variableName, string resourceName, IMvxAndroidCurrentTopActivity topActivity)
{
try
{
return topActivity.Activity.Resources.GetIdentifier(variableName, resourceName, topActivity.Activity.PackageName);
}
catch (Exception)
{
return -1;
}
}
}
The XML view:
The Icon property I'm binding is a string like: "icon_name" where I put the image icon_name.png in the Android project's Resources/drawable