我有一个默认警报对话框,其中包含文本列表视图&单选按钮。如何更改Android默认警报对话框的背景颜色
&还需要更换警报对话框的背景颜色,我需要替换图片而不是文字(替换图片而不是Facebook信用卡,贝宝,信用卡如下所示)。
我也将style.xml文件放入值文件夹中。
如何在下面的代码中实现该文件以更改背景颜色?
我的代码:
final CharSequence[] items = {"Facebook credit", "Paypal", "Credit Card"};
//ContextThemeWrapper ctw = new ContextThemeWrapper(this, R.style.AboutDialog);
AlertDialog.Builder builder = new AlertDialog.Builder(paymentPage.this);
builder.setTitle("Payment Gateway");
builder.setIcon(R.drawable.gate);
builder.setSingleChoiceItems(items, -1, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
// Toast.makeText(getApplicationContext(), items[item], Toast.LENGTH_SHORT).show();
}
});
builder.setPositiveButton("Yes",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
payPalPayment();
}
});
builder.setNegativeButton("No",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
Toast.makeText(paymentPage.this, "Fail", Toast.LENGTH_SHORT).show();
}
});
AlertDialog alert = builder.create();
alert.show();
}
});
我的形象:
我建议你[创建一个自定义对话框(http://developer.android.com/guide/topics/ui/dialogs.html#CustomDialog )。 – iTurki 2012-08-13 07:29:52