[英]How to upload image from gallery to android?
我正在开发一个包含上传图片的应用程序,我可以使用以下方法选择图片。 通过这种方式,它直接带我进入画廊,在带我进入画廊之前,如何显示警报(如whatsapp个人资料图片更改)。
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_PICK);
startActivityForResult(intent, PICK_IMAGE_R);
当用户单击您的按钮或选择照片时,您可以弹出一个对话框片段:
AlertDialog.Builder builder=new AlertDialog.Builder(MainActivity.this);
builder.setTitle("Set a Profile Photo");
final String[] Items={"Select a Profile Photo"}; // You can add more choices here
builder.setItems(Items, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
if (i == 0){
// Your code to launch gallery here
}
}
});
builder.setCancelable(true);
AlertDialog dialog=builder.create();
dialog.show();
在此处查看更多示例: https : //github.com/msandroid/AndroidUsefulExample_AlertDialog
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.