我在 main.xml 中有一个 Imageview,如何将位图设置为 main.xml 中的 imageView 我可以在下面的代码中将位图分配给本地图像视图。
//Activates the Camera
Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
startActivityForResult(intent, 1);
// get the bitmap data from the Camera
Bundle extras = data.getExtras();
Bitmap b = (Bitmap) extras.get("data");
int width = b.getWidth();
int height = b.getHeight();
ImageView img = new ImageView(this);
img.setImageBitmap(b);
//Saves the image
MediaStore.Images.Media.insertImage(getContentResolver(), b, timestamp, timestamp);
// Set the View
setContentView(img);