动态设置listview项目中的imageview速度很慢
问题描述:
我遇到了列表视图项目的问题。我动态地从XML文件中获取一些图像,下载图像并设置它。动态设置listview项目中的imageview速度很慢
我想基本上缓存位图抓取,以加快我的列表视图适配器的getView过程。但是当试图滚动我的列表视图时,手机似乎“滞后”。
这是我的代码的一部分,负责“滞后”:
if(ni.Bitmap == null)
{
Pattern p = Pattern.compile("<img[^>]+src\\s*=\\s*['\"]([^'\"]+)['\"][^>]*>");
Matcher m = p.matcher(ni.Description);
boolean result = m.find();
if(result)
{
try {
Bitmap bitmap = BitmapFactory.decodeStream((InputStream)new URL(m.group(1)).getContent());
ni.Bitmap = bitmap;
holder.theimage.setImageBitmap(ni.Bitmap);
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
else
holder.theimage.setImageBitmap(ni.Bitmap);
可我反正加速这一进程?
您的链接激发了我的一些解决方案 - 谢谢... – Repox 2011-03-11 14:24:04