0

我为我的播客应用程序编写了一个 rss 解析器。如果我用不同的播客解析 rss 提要并在 a 中显示结果,ListView我的解析器解析整个提要大约需要 1-2 秒。

但是,如果我想在ListViewBitmapFactoryImageView.

不幸的是,这将我的执行时间从 1-2 秒延长到了 8-10 秒。

这就是我抓取缩略图的方式。有没有更好(更快)的方法来实现我想做的事情,如果有,我该如何实现?

提前致谢。

...
else if (name.equalsIgnoreCase(THUMBNAIL)) {
    HttpGet get = new HttpGet(parser.nextText());
    if (get != null && get.getURI().toString().length()>1) {
        HttpClient client = new DefaultHttpClient();
        HttpResponse response = client.execute(get);
        if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
            HttpEntity entity = response.getEntity();
            if (entity != null) {
                byte[] bb = EntityUtils.toByteArray(entity);
                currentItem.setBitmap(BitmapFactory.decodeByteArray(bb, 0, bb.length));
            }
     }
}
4

1 回答 1

1

您应该使用单独的线程来下载位图。这称为延迟加载。请参阅我的教程: http: //negativeprobability.blogspot.com/2011/08/lazy-loading-of-images-in-listview.html

或这个问题的答案: ListView 中的图像延迟加载

于 2011-08-27T15:05:29.117 回答