Это изображение AlertDialog, которое отображается в моем приложении. Он должен иметь кнопки отказа и принятия.
Как видите, нет:
Я не могу воспроизвести эту ошибку, так как у меня нет телефона с Android 7.1. Фотография была сделана на Google Pixel и отправлена мне.
Во всех других версиях Android, на которых тестировалось это приложение, эта ошибка не обнаружена. (Версии 4.1, 6.0.1)
Вот код метода создания диалога:
/**
* Creates a 2 options dialog.
* @param context
* @param title headline of the dialog
* @param message main text of the dialog
* @param accept listener for the accept button
* @param deny listener for deny button
* @param acceptText text of the positive answer button
* @param denyText text of the negative answer button
* @param cancelable weather a click to anywhere but the presented buttons dismisses the dialog
* @return a created dialog instance. To display it call show()
*/
public static AlertDialog createAcceptDenyDialog(Context context,
String title, String message, String acceptText,
String denyText, boolean cancelable,
DialogInterface.OnClickListener accept,
DialogInterface.OnClickListener deny,
DialogInterface.OnDismissListener dismiss){
AlertDialog.Builder alertDialog = new AlertDialog.Builder(context)
.setTitle(title)
.setMessage(message)
.setPositiveButton(acceptText, accept)
.setNegativeButton(denyText, deny)
.setCancelable(cancelable)
.setOnDismissListener(dismiss);
return alertDialog.create();
}
Это код, вызывающий отображение диалога:
public void showRequestErrorRetryDialog(String title, String message) {
Dialog dialog = DialogFactory.createAcceptDenyDialog(this
, title
, message
, getString(R.string.retry_button)
, getString(R.string.abort_button)
, true
, (dialogInterface, i) -> {
onStartServerCommunication();
showProgressOverlay();
}
, null
, null);
dialog.show();
}
Как видите, я использую ретролямбду.
Кто-нибудь знает, что происходит?
this
в вашем методе? Что отлично работает для меня в Android 7, так этоnew AlertDialog.Builder(context).attributes.show()
.. (Атрибуты - это все методы, такие как.setTitle()
.setPositiveButton()
и т. д.. - person creativecreatorormaybenot   schedule 15.01.2017