title: Android - Images from Assets folder in a GridView
body: <p>I have been working on creating a Grid View of images, with images being present in the Assets folder. <a href="https://stackoverflow.com/questions/1933015/opening-an-image-file-inside-the-assets-folder">Opening a File from assets folder in android</a> link helped me with using the bitmap to read it. The code am currently having is:</p>
  
  <pre><code> public View getView(final int position, View convertView, ViewGroup parent) 
  {
  
    try 
      {
       AssetManager am = mContext.getAssets();
       String list[] = am.list("");
       int count_files = imagelist.length;
       for(int i= 0;i&lt;=count_files; i++)
       {
        BufferedInputStream buf = new BufferedInputStream(am.open(list[i]));
        Bitmap bitmap = BitmapFactory.decodeStream(buf);
        imageView.setImageBitmap(bitmap);
        buf.close();
       }
     }   
     catch (IOException e) 
     {
     e.printStackTrace();
     }
    }
  </code></pre>
  
  <p>My application does read the image from the Assets folder, but it is not iterating through the cells in the grid view. All the cells of the grid view have a same image picked from the set of images. Can anyone tell me how to iterate through the cells and still have different images ?</p>
  
  <p>I have the above code in an ImageAdapter Class which extends the BaseAdapter class, and in my main class I am linking that with my gridview by:</p>
  
  <pre><code>    GridView  gv =(GridView)findViewById(R.id.gridview);
      gv.setAdapter(new ImageAdapter(this, assetlist));       
  </code></pre>
  
  <p>Thanks a lot for any help in advance,
  Saran</p>