我有一个相机应用程序,带有多个相机按钮。代码如下。
class btnTakePhotoClicker implements Button.OnClickListener
{
int k;
public btnTakePhotoClicker(int k) {
this.k = k;
}
@Override
public void onClick(View v) {
capture_img = (ImageButton)view.get(k).findViewById(R.id.clickme);
capture_img.setClickable(false);
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST);
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == CAMERA_PIC_REQUEST) {
capture_img = (ImageButton)view.get(cameraIndex[idx]).findViewById(R.id.clickme);
Bitmap thumbnail = (Bitmap) data.getExtras().get("data");
capture_img.setImageBitmap(thumbnail);
}
}
现在我想将索引 k 传递给 onactivityResult。请指导如何做同样的事情。