我正在开发包含上传图片的应用,我可以使用以下选择图片。通过它直接将我带到画廊,如何在我带到画廊之前显示警报(如whatsapp个人资料图片更改)。
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_PICK);
startActivityForResult(intent, PICK_IMAGE_R);
答案 0 :(得分:0)
当用户点击您的按钮或选择照片时,您可以弹出一个对话框片段:
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