我试图将我点击/选择的图像发送到新活动这是我的代码
public int getCount() {
return mThumbIds.length;
}
public View getView(final int position, View convertView, ViewGroup parent) {
ImageView imageView;
if (convertView == null) { // if it's not recycled, initialize some attributes
imageView = new ImageView(mContext);
imageView.setLayoutParams(new GridView.LayoutParams(85, 85));
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
imageView.setPadding(8, 8, 8, 8);
imageView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent intent = new Intent(mContext,HeroData.class);
intent.putExtra("imageID", position);
mContext.startActivity(intent);
}
});
} else {
imageView = (ImageView) convertView;
}
imageView.setImageResource(mThumbIds[position]);
return imageView;
}
private Integer[] mThumbIds = {
R.drawable.pic1, R.drawable.pic12,
R.drawable.pic2, R.drawable.pic13,
R.drawable.pic3, R.drawable.pic14,
};
}
并尝试在新活动中接收它
Bundle bdl = getIntent().getExtras();
int index = bdl.getInt("imageID");
ImageView image = (ImageView) findViewById(R.id.imageview);
image.setImageResource();//the problem ! how to receive the selected image
我想知道我正在发送(“imageID”,位置);如何获取选定的图像