【发布时间】:2017-06-29 00:48:29
【问题描述】:
我使用 AlertDialog (android.support.v7.app.AlertDialog) 来显示游戏级别,如下所示
AlertDialog dialog;
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), R.style.DialogLevelsStyle);
LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.dialog_game_level, null);
builder.setView(view)
.setCancelable(false)
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (dialog != null) {
dialog.cancel();
}
}
});
dialog = builder.create();
dialog.show();
//styles.xml
<style name="DialogLevelsStyle" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="colorAccent">#3caaf0</item>
</style>
但对话框在警告对话框的按钮右侧显示肯定按钮确定,请帮助我!
【问题讨论】:
-
试试 setNeutralButton()。
-
使用 setNeutralButton() 显示在 AlertDialog 的左下角