0

I am getting a error, "cannot generate texture from bitmap" when trying to populate a listview with images. I am using aquery to download, caching and retrieving them.

I have an ArrayAdapter, and a serie of "News" objects, wich have, title, text and a image url. In the adapter i call the "setImage" method from the corresponding News object, passing the reference of the imageview in which view i want to show the image. Here is the code, responsible of getting the image and caching it:

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

Thanks!

alvaropgl
  • 830
  • 8
  • 19

1 Answers1

0

Try below code:-

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