【发布时间】:2011-03-02 09:15:20
【问题描述】:
我的列表视图项目有问题。我从 XML 文件中动态获取一些图像,下载图像并设置它。
我正在尝试以原始方式缓存获取的位图,以加快我的 listviews 适配器的 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);
无论如何我可以加快这个过程吗?
【问题讨论】:
标签: android profiling imageview