Hey guys how are you doing? i have setup a gallery view for my application and i would like to load images in this view from a specific image folder on my sdcard. Can someone please help me, as i searched alot and none of the provided solutions worked.
I have successfuly managed to load images from the RES/DRAWABLE folder into my gallery view, but never succeeded in my original plan.
This is the imageadapter class i use where i load the images from the RES/DRAWABLE folder
public class ImageAdapter extends BaseAdapter
{
public ImageAdapter(Context c)
{
mContext = c;
}
public int getCount()
{
return mThumbIds.length;
}
public Object getItem(int position)
{
return position;
}
public long getItemId(int position)
{
return position;
}
public View getView(int position, View convertView, ViewGroup parent)
{
ImageView imageView;
if (convertView == null)
{
imageView = new ImageView(mContext);
imageView.setLayoutParams(new Gallery.LayoutParams(100, 100));
imageView.setAdjustViewBounds(false);
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
imageView.setPadding(18, 18, 18, 18);
}
else
{
imageView = (ImageView) convertView;
}
imageView.setImageResource(mThumbIds[position]);
return imageView;
}
private Context mContext;
private Integer[] mThumbIds =
{
R.drawable.image_1,
R.drawable.image_2,
R.drawable.image_3,
R.drawable.image_4
};
}
Here is a tutorial I used to do exactly what you want. If it doesn't help I can post the code I used to grab pictures that are stored directly on the device (not the sd card).