我有一个默认的警告对话框,其中包含文本和单选按钮的listview。
我需要用图像替换文本(替换下面显示的Facebook信用、PayPal、信用卡),并且还需要更改警告对话框的背景颜色。
我将style.xml文件放在values文件夹内。
如何在下面的代码中实现该文件以更改背景颜色?
我的代码:
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();
}
});
我的图片: