I have a default alert dialog with listview of Text & Radio buttons.
I need to replace the image instead of text (Replace images instead of Facebook credit,paypal,Credit card shown below) & also needs to change alert dialog's background color.
I put style.xml file inside values folder also.
How could I implement that file in below code for changing background color?
My code:
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();
}
});
My image:
You should Customize AlertDialog Theme. Look at following post.
https://sites.google.com/site/androidhowto/how-to-1/customize-alertdialog-theme
This library might help you : https://github.com/avast/android-styled-dialogs
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With