AlertDialog.Builder builder = new AlertDialog.Builder(mActivity,
R.style.MyAlertDialogStyle);
builder.setTitle(mActivity.getResources().getString(R.string.app_name));
builder.setCancelable(false);
builder.setMessage(str_message);
builder.setPositiveButton(str_btn1,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
if (listener != null) {
listener.onClick(null);
}
}
});
if (str_btn2 != null) {
builder.setNegativeButton(str_btn2,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface,
int i) {
if (listener2 != null) {
listener2.onClick(null);
}
}
});
}
builder.show();
Edit : Please see the image above. You will get the output like this. Simply create a dialog style
Dialog Style in styles.xml
<style name="MyAlertDialogStyle" parent="Theme.AppCompat.Light.Dialog.Alert"> <!-- Used for the buttons -->
<item name="android:textStyle">bold</item>
<item name="colorAccent">@android:color/holo_blue_bright</item>
<!-- Used for the title and text -->
<item name="android:textColorPrimary">@android:color/black</item>
<!-- Used for the background -->
<item name="android:background">@android:color/white</item>
</style>