How To Put Taken Image In Specific Image View
I have an activity that contain a grid view which contain 3 card view each has an image view I want to setonclick mistenr that put the taken iamge from camera to the selected image
Solution 1:
Send different requestCode
for different imageView
click, And onActivityResult
check the request code set image data to your imageView
capturedImageButton.setOnClickListener( new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent photoCaptureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(photoCaptureIntent, 100);
}
});
capturedImageButton1.setOnClickListener( new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent photoCaptureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(photoCaptureIntent, 101);
}
});
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(resultCode == RESULT_OK){
switch (this.resultCode){
case 100:
Bitmap bitmap = (Bitmap)data.getExtras().get("data");
capturedImageButton.setImageBitmap(bitmap);
break;
case 101:
Bitmap bitmap = (Bitmap)data.getExtras().get("data");
capturedImageButton1.setImageBitmap(bitmap);
break;
default:
break;
}
}
}
Post a Comment for "How To Put Taken Image In Specific Image View"