我想成立一个的TextView
与 SpannableString
这是从下面的方法:
I want to set a TextView
with SpannableString
which is from the method below:
Html.fromHtml(String source, Html.ImageGetter imageGetter,
Html.TagHandler tagHandler)
但 ImageGetter
这里需要覆盖下面的方法:
But the ImageGetter
here need to override the method below:
public abstract Drawable getDrawable(String source)
由于我需要从互联网上获得的绘制,我也要异步做到这一点,看来事实并非如此。
Because I need to get the drawable from the internet, I have to do it asynchronously and seems it is not.
如何使它工作? 谢谢你。
How to make it work? Thanks.
现在我使用的AsyncTask下载图像的 ImageGetter
:
Now I'm using an AsyncTask to download the images in the ImageGetter
:
Spanned spannedContent = Html.fromHtml(htmlString, new ImageGetter() {
@Override
public Drawable getDrawable(String source) {
new ImageDownloadAsyncTask().execute(textView, htmlString, source);
return null;
}
}, null);
和重新设置文成的TextView
图像已被下载的时候。
And set the text again into the TextView
when the image has been downloaded.
现在它的作品。但是失败了,当我试图做 TextView.postInvalidate()
重绘下载的图像。我必须在的setText()
再这样做了的AsyncTask
。
Now it works. But It failed when I tried to do the TextView.postInvalidate()
to redraw the downloaded images. I have to do setText()
again in the AsyncTask
.
有谁知道为什么吗?
上一篇:从屏幕上方慢慢降标记位置上的Android地图V2标记、屏幕、位置、地图
下一篇:解析的Youtube的GData JSON成的ListViewGData、Youtube、ListView、JSON