我正在开发一个相机应用程序,它显示多个图像动态添加到一个简单的 LinearLayout 作为 child 。选择特定图像时 (onClick),它会转到相机 View (相机 Intent )。该应用程序应该显示在正确选择的 ImageView 中捕获的新图像。问题是,我不知道如何让特定的 ImageView 在 onActivityResult 方法中处理它。请帮忙
最佳答案
在你的onActivityResult()
if (resultCode == RESULT_OK) {
if (data != null) {
Bitmap thumbnail = (Bitmap) data.getExtras().get("data");
imageView.setImageBitmap(thumbnail);
}
}
data
是 Intent 。
您可以在打开相机应用程序之前保存被点击的 ImageView
的引用,并使用该引用来设置新图像。
更新:只需在您的 Activity 中创建一个ImageView
变量,然后在您打开相机之前,将点击的实例放入此字段,并使用此ImageView
在我的示例代码中。
关于在 LinearLayout 中包含多个图像的 Android Camera App,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11341852/