0
我想獲得文本作爲跨越,以獲得文本的html視圖。 但是,我不想要images.Is那可能嗎?如何從imageGetter獲得空白圖像
這是我的代碼:
Spanned description2=Html.fromHtml(des.get(position),null,null);
TextView text = (TextView) dialog.findViewById(R.id.descr);
text.setText(description2);
但它返回我一些綠色的框,這一點我不想要的照片請幫忙
帶有圖像:
字符串內容描述2 = des.get (位置)的ToString();
Spanned description = Html.fromHtml(description2, new ImageGetter() {
@Override
public Drawable getDrawable(String source) {
Drawable d = null;
try {
InputStream src = imageFetch(source);
d = Drawable.createFromStream(src, "src");
if(d != null){
d.setBounds(0,0,d.getIntrinsicWidth(),
d.getIntrinsicHeight());
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return d;
}
public InputStream imageFetch(String source)
throws MalformedURLException,IOException {
URL url = new URL(source);
Object o = url.getContent();
InputStream content = (InputStream)o;
// add delay here (see comment at the end)
return content;
}
},null);
感謝隊友,這有效!但是,如果我想獲取圖像,有一個很大的延遲,直到圖像加載..有沒有辦法解決它?一般來說,是一個好主意,使用spanned獲取圖像和來自rss的文字? – user1156210
即時通訊問,因爲用這種方式,綠色方塊消失(正如我們想要的),但仍然存在的空間.. – user1156210
如果你想獲得圖像,那麼你必須重寫ImageGetter不同,你可以開始一個線程將使用處理程序或AsyncTask下載所有圖像並在屏幕上顯示它們。 – Rotemmiz