【问题标题】:Using Aquery: cannot generate texture from bitmap使用 Aquery:无法从位图生成纹理
【发布时间】:2014-04-30 19:30:27
【问题描述】:

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

我有一个 ArrayAdapter 和一系列“新闻”对象,其中有标题、文本和图像 url。 在适配器中,我从相应的 News 对象调用“setImage”方法,传递我想要在哪个视图中显示图像的 imageview 的引用。这是代码,负责获取图像并对其进行缓存:

    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);       
        }   
    }

谢谢!

【问题讨论】:

    标签: android android-query aquery


    【解决方案1】:

    试试下面的代码:-

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-28
      • 2011-01-23
      • 1970-01-01
      • 1970-01-01
      • 2016-08-26
      • 2017-07-04
      相关资源
      最近更新 更多