Skip to content Skip to sidebar Skip to footer

Extract Arraylist Values From Adapter To Gridview

I can find plenty of examples of how to use ArrayList in the BaseAdapter class to fill a GridView, but I am having difficulty passing the correct values. This was working fine whi

Solution 1:

In activity, use below code for saving the ImageId to the ArrayList.

if (getCursor != null) {
    while (getCursor.moveToNext()) {
      columnIndex = getCursor.getColumnIndexOrThrow(projection[0]);  
      imageCollection.add(String.valueOf(getCursor.getLong(columnIndex));
    }
 }

In ImageAdapter, getView method, get the ImageId by using below code:

String imageID  = tempCollection.get(position);

Post a Comment for "Extract Arraylist Values From Adapter To Gridview"