这个实际中很多,为了使用方面我就专门拿出来为了以后简单
public void onItemClick(AdapterView<?> parent, View v, int pos, long id) {
String imagename = getResources().getResourceName((Integer)parent.getItemAtPosition(pos));
imagename = imagename.substring(imagename.indexOf('/')+1,imagename.length());
Toast.makeText(getApplicationContext(),"pic "+imagename, Toast.LENGTH_SHORT).show();
Intent i = new Intent(this, OneImageViewer.class);
i.putExtra("image",(Integer)parent.getItemAtPosition(pos));
i.putExtra("imagename",imagename);
startActivityForResult(i, CREATE_REQ);
}
取其中的值
Bundle extras = getIntent().getExtras();
if (extras != null) {
Integer resloc = (Integer)extras.get("image");
String imgname = (String)extras.get("imagename");
if (resloc != null && imgname != null) {
title.setText(imgname);
img.setScaleType(ImageView.ScaleType.CENTER_CROP);
img.setPadding(10,10,10,10);
img.setImageResource(resloc);
}
}