使用 Aquery:无法从位图生成纹理



尝试用图像填充列表视图时出现错误"无法从位图生成纹理"。我正在使用查询来下载,缓存和检索它们。

我有一个ArrayAdapter,以及一系列"新闻"对象,包括标题,文本和图像URL。在适配器中,我从相应的新闻对象调用"setImage"方法,传递图像视图的引用,我想在其中显示图像。这是代码,负责获取图像并缓存它:

    private String image //url of the image to download
    private Bitmap imagebmp; //To store the cached image
    public void setImage(ImageView imgview, AQuery aq)
    {       
        if (imagebmp==null || imagebmp.isRecycled()) 
        {
            Bitmap bm = aq.getCachedImage(image);
            if (bm==null || bm.isRecycled())                     
                aq.id(imgview).image(image);
            else {
                imgview.setImageBitmap(bm);
                imagebmp = bm;
            }       
        } else {
            imgview.setImageBitmap(imagebmp);       
        }   
    }

谢谢!

尝试以下代码:-

File file = aq.getCachedFile("http://android.programmerguru.com/wp-content/uploads/2014/01/asynctask_thumb.png");
aq.id(R.id.image1).image(file, 300);

最新更新