Код: Выделить всё
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) CONTEXT.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rowView = inflater.inflate(R.layout.rss_items_listview_layout, parent, false);
TextView tvItemList = (TextView)rowView.findViewById(R.id.tvItemList);
String content = null;
RssItemFull item = getItem(position);
if(item.getEnclosure() != null) {
content = "<html><head><meta charset='"+ item.getEncoding() +"'>" +
"</head><body><p><img src='" +
item.getEnclosure() + "'>" + item.getTitle() +"<br>" + item.getDate() +"</p></body></html>";
}
else {
content = "<html><head><meta charset='" + item.getEncoding() +"'>" +
"</head><body><p align='center'>" + item.getTitle() + "</p><br><p align='center'>" +
item.getDate() + "</p></body></html>";
}
Spanned s = Html.fromHtml(content, new ImageGetter() {
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, 70, 70);
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return d;
}
}, null);
tvItemList.setText(s);
return rowView;
}
public InputStream imageFetch(String source) throws MalformedURLException,IOException {
URL url = new URL(source);
Object o = url.getContent();
InputStream content = (InputStream)o;
return content;
}