android romoteviews setTextViewText中使用HTML出现问题

最近碰到一个问题,romoteviews使用HTML解析图片解析不出来,代码如下:
views.setTextViewText(R.id.text_content,
Html.fromHtml("abc", new Html.ImageGetter(){
@Override
public Drawable getDrawable(String source){
Drawable myDrawable = null;
File imageFile = new File(source);
myDrawable = zoomDrawable(imageFile);//这是用于缩放
myDrawable.setBounds(0 , 0, myDrawable.getIntrinsicWidth(),
myDrawable.getIntrinisicHeight());
return myDrawable;
}

}, null));
最后解析出的图片显示OBJ,这个问题困惑已久,有哪位大侠晓得原因吗?请指教,不胜感激!

看代码,代码的问题可能在于以下两个方面:

  • 从HTML中获取图片的地址是否正确,Html.fromHtml函数第一个参数是HTML字符串,但是它不包含图片地址,所以图片地址可能是错误的。

  • 图片是否存在,因为您使用File对象来读取图片,所以您需要确保图片是否存在,并且图片是否可读。