I am trying to show a img in Base64 with Html.fromHtml
I have a tag with Base64 string of one image.
That is my code:
public class GlossaryAdapter extends BaseAdapter{
...
private Resources res;
public GlossaryAdapter(Context context, ...) {
this.res = context.getResources();
...
}
public View getView(int position, View convertView, ViewGroup arg2) {
...
holder.tvContent.setText(Html.fromHtml(glossary.getContent(), new Html.ImageGetter() {
@Override
public Drawable getDrawable(String source) {
try {
byte[] data;
data = Base64.decode(source,Base64.DECODE);
Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);
return new BitmapDrawable(res, bitmap);
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
}, null));
glossary.getContent() contains:
I tested this string in a html page and works. Show the image.
I got no errors. But nothing is showing.
If I change the return to 'null' I got a small gray square.
any ideas?