【发布时间】:2015-09-15 11:57:02
【问题描述】:
我有 3 个 Imageview。我只想在 android 中捕获 3 个图像并分别显示在 3 个 imageview 中。
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
this.imageView = (ImageView)this.findViewById(R.id.imageView1);
this.imageView1 = (ImageView)this.findViewById(R.id.imageView2);
this.imageView2 = (ImageView)this.findViewById(R.id.imageView3);
Button photoButton = (Button) this.findViewById(R.id.button1);
Button photoButton1 = (Button) this.findViewById(R.id.button2);
Button photoButton2 = (Button) this.findViewById(R.id.button3);
photoButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, CAMERA_REQUEST);
}
});
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == CAMERA_REQUEST && resultCode == RESULT_OK) {
Bitmap photo = (Bitmap) data.getExtras().get("data");
imageView.setImageBitmap(photo);
}
}
}
这是我的代码,但我无法在三个 diff 图像视图上设置图像 我的想法是在三个按钮上打开相机并在各自的图像视图上显示图像
【问题讨论】:
-
你尝试了什么?
-
请向我们展示您的代码。
-
它如此简单的用户请求代码作为区分值。您可以检查 onActivityResult 从哪个请求代码活动开始,这也将告诉按钮单击。签入 onActivityResult 这个请求代码并在各自的图像视图上添加图像。