我有一个警告对话框,它不显示我使用“setIcon”设置的图标。
我使用Android Studio和Android Emulator API 19/Android 4.4.2。Android - AlertDialog中未显示图标
我可以运行该应用程序,对话框显示没有图标,没有错误。
但Android Studio标记包含“setIcon”的行,并提供给我“引入本地变量”和“使方法调用链进入调用序列”
所以我的问题:为什么图标不显示?
我的代码:
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder
.setMessage("Repeat game?")
.setIcon(android.R.drawable.ic_dialog_alert) //<--- icon does not show
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
//Yes button clicked, do something
}
})
.setNegativeButton("No", null) //Do nothing on no
.show();
.setIconAttribute(android.R.attr.alertDialogIcon) – 2017-10-05 05:09:28