我已经成功地将RES / DRAWABLE文件夹中的图像加载到我的图库视图中,但从未在我的原始计划中成功。
这是我使用的imageadapter类,我在其中加载RES / DRAWABLE文件夹中的图像
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
};
}