我有图像,我希望它们在画廊中使用适配器来选择每个图像,它将使用画布绘制,我看了很多教程并编写了代码,现在我不知道我在哪里做错了
Gallery g;
ImageAdapter imageAdapter;
Gallery g = (Gallery) findViewById(R.id.gBitmap);
imageAdapter = new ImageAdapter(this);
g.setAdapter(imageAdapter);
//selected Bitmap from gallery
g.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent,
View v, int position, long id) {
applyBitmap(position);
}
});
}
public class ImageAdapter extends BaseAdapter {
int mGalleryItemBackground;
private Context mContext;
private Integer[] mImageIds = {
R.drawable.first,
R.drawable.second,
R.drawable.fifth,
R.drawable.third,
R.drawable.fourth,
public ImageAdapter(Context c) {
mContext = c;
}
public int getCount() {
return mImageIds.length;
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
public View getView(int position,
View convertView, ViewGroup parent) {
return iv;
}
}
public static void Bitmap(int position) {
BitmapFactory.Options opt = new BitmapFactory.Options();
opt.inScaled = true;
opt.inPurgeable = true;
opt.inInputShareable = true;
Bitmap brightBitmap = BitmapFactory.decodeResource(null, position, opt);
iv.setImageBitmap(brightBitmap);
}
我需要选择mImageIds
使用我的函数调用Bitmap