当我在两个选项之间选择时,如何更改文本的颜色'图库'和#39;相机'。我希望他们两个都是橙色的。 另外,我如何添加一个图标/图像来代表画廊'和#39;相机',所以当选择图标时,它会带我进入图库,这样我就可以选择图像,或者我可以使用相机拍照。
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.launch_voip_call) {
Utils.startCall(this, contact);
return true;
} else if (item.getItemId() == R.id.launch_camera) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("Pick Image from")
.setPositiveButton("Camera", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
//camera intent
Intent cameraIntent = new Intent(ConversationActivity.this, CameraActivity.class);
cameraIntent.putExtra("EXTRA_CONTACT_JID", contact.getJid());
startActivity(cameraIntent);
}
})
.setNegativeButton("Gallery", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
Intent intent = new Intent();
// Show only images, no videos or anything else
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
// Always show the chooser (if there are multiple options available)
startActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST);
}
});
AlertDialog alert = builder.create();
alert.show();
}
}