
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: Пожалуйста, смотрите изображение выше. Вы получите результат следующим образом. Просто создать диалоговый стиль
Dialog Style в 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>
взглянуть на это для начала: http://stackoverflow.com/questions/13341560/how-to-create-a-custom -dialog-box-in-android – Zaki
Возможно [этот вопрос SO] (http://stackoverflow.com/questions/18352324/how-can-can-i-add-custom-buttons-into-an-alertdialogs-layout) может быть с некоторой помощью –
Спасибо, @Zaki. Похоже на то, что я мог бы попробовать. – etilia