作者:紫色冰姬YOU | 来源:互联网 | 2023-01-25 15:57
两种方案:
1、弹出activity类型的对话框:
2、如果嫌第一种麻烦,那就getwindow(),让你的对话框显示在你取的window上;
第一种已经写过了
第二种:
先在manifest理添加权限
int themeID = getResources().getIdentifier("androidhwext:style/Theme.Emui.Dialog.Alert",null,null); //适配主题
AlertDialog.Builder builder = new AlertDialog.Builder(this,themeID);
builder.setTitle(R.string.wifi_is_disconnect);
builder.setPositiveButton(R.string.open_confirm,new OpenDataConnectOKListener());
builder.setNegativeButton(R.string.cancle_confirm, new CloseDataConnectOKListener());
mAlertDialog = builder.create();
final View layout = mAlertDialog.getLayoutInflater().inflate(R.layout.define_view_dialog,null);
mCheckbox = (CheckBox) layout.findViewById(R.id.closeReminder);
mAlertDialog.setView(layout);
mAlertDialog.setCanceledOnTouchOutside(false);//屏蔽返回键
//mAlertDialog.setCancelable(false);
mAlertDialog.getWindow().setType(
WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);//获取window显示对话框