我正在使用带有 anImageView
和 2的自定义对话框Button
。
- 从图库中选择图像的第一个按钮
- 第二个按钮单击来自相机的图像
我想在ImageView
对话框中显示图像..
btn1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Dialog();
}
private void Dialog() {
// TODO Auto-generated method stub
final Dialog dialog=new Dialog(editevent1.this);
dialog.setContentView(R.layout.promote2);
ImageView image =(ImageView)findViewById(R.id.image_camera);
Button d=(Button)dialog.findViewById(R.id.button2);
Button f=(Button)dialog.findViewById(R.id.button3);
dialog.show();
d.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent intent = new Intent(Intent.ACTION_PICK);
intent.setType("image/*");
startActivityForResult(intent, 1);
}
});
f.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent cameraintent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraintent, CAMERA_PIC_REQUEST);
}
});
}
});
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
super.onActivityResult(requestCode, resultCode, data);
if( requestCode == CAMERA_PIC_REQUEST)
{
Bitmap thumbnail = (Bitmap) data.getExtras().get("data");
ImageView image =(ImageView)findViewById(R.id.image_camera);
image.setImageBitmap(thumbnail);
}
else
{
Toast.makeText(this, "Picture NOt taken", Toast.LENGTH_LONG);
}
}
请告诉我如何获得从图库中选择和从相机中单击时的图像ImageView
。DialogBox
谢谢