我使用的下面代碼從 gallery 和 Camerra 獲取圖像
upload.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
AlertDialog.Builder builder = new AlertDialog.Builder(CreatePod.this);
builder.setMessage("Select") .setCancelable(false).setPositiveButton("Gallery", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
Intent gallIntent=new Intent(Intent.ACTION_GET_CONTENT);
gallIntent.setType("image/*");
startActivityForResult(gallIntent, 10);
}
})
.setNegativeButton("Camera", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, 0);
}
});
AlertDialog alert = builder.create();
if (bitmap == null) {
Toast.makeText(getApplicationContext(),
"Please select image", Toast.LENGTH_SHORT).show();
} else {
dialog = ProgressDialog.show(CreatePod.this, "Uploading",
"Please wait...", true);
//new ImageUploadTask().execute();
}
}
});
但是沒有運行成功。我也沒有看到一個對話框。
請大家指點一二,謝謝!
private OnClickListener clicklistener = new OnClickListener() {
@Override
public void onClick(View v) {
if (bitmap == null) {
Toast.makeText(getApplicationContext(),
"Please select image", Toast.LENGTH_LONG).show();
} else {
Dialog dialog = ProgressDialog.show(getApplicationContext(), "Uploading",
"Please wait...", true);
//new ImageUploadTask().execute();
}
}
};