ユーザーをカメラに誘導するボタンを使用して、画像を撮影したときにimageViewに表示することができます。ここで
はコードです: -
ImageView im =(ImageView)findViewById(R.id.imageid); //Your image View
Button b=(Button)findViewById(R.id.Buttonid); // your Button
b.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent img = new Intent(); //Your Intent
img.setAction(MediaStore.ACTION_IMAGE_CAPTURE); //the intents action to capture the image
startActivityForResult(img,1);//start the activity adding any code .1 in this example
}
});
protected void onActivityResult(int requestCode,int resultCode,Intent data){
super.onActivityResult(requestCode,resultCode,data);//method retrieves the requestCode , its result and the data containing the pic from system
if(requestCode==1&&resultCode==RESULT_OK){
Bitmap photo = (Bitmap)data.getExtras().get("data"); //get data and casts it into Bitmap photo
im.setImageBitmap(photo);// set photo to imageView
}