【发布时间】:2014-06-24 18:07:59
【问题描述】:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode != Activity.RESULT_CANCELED) {
if (requestCode == PICK_IMAGE) {
Uri selectedImageUri = data.getData();
Log.d("PICK_IMAGE", selectedImageUri.toString());
Dialog settingsDialog = new Dialog(this);
settingsDialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
settingsDialog.setContentView(getLayoutInflater().inflate(R.layout.custom_dailogue, null));
img_in_dailogue = (ImageView) findViewById(R.id.img_in_dailogue);
ImageView img_in_dailogue = new ImageView(this);
LinearLayout.LayoutParams vp = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
img_in_dailogue.setLayoutParams(vp);
img_in_dailogue.setMaxHeight(250);
img_in_dailogue.setMaxWidth(350);
img_in_dailogue.setImageURI(Uri.parse(selectedImageUri.toString()));
settingsDialog.show();
}
}
}
Logcat 错误
- java.lang.RuntimeException: 传递结果失败 ResultInfo{who=null, request=0, result=-1, data=Intent { dat=content://media/external/images/media/232 flg=0x1 } } 到活动 {com.leadconcept.whopopsup/com.leadconcept.whopopsup.CameraActivity}:java.lang.NullPointerException
- 在 com.leadconcept.whopopsup.CameraActivity.onActivityResult(CameraActivity.java:131)
第二个 logcat 错误将我带到这行代码:
img_in_dailogue.setImageURI(Uri.parse(selectedImageUri.toString()));
该代码有什么问题?我不明白为什么我不能将 imageUri 发送到 imageview。我还验证了我传递给 setImageURI 函数的 Uri 值是正确的。
【问题讨论】:
标签: android android-intent imageview android-gallery