AlertDialog获取Button,点击外围不消失,设置样式

来源:互联网 发布:燕郊淘宝店招聘 编辑:程序博客网 时间:2024/06/06 23:19
private AlertDialog AlertDialogShow(String message){    AlertDialog.Builder builder = new AlertDialog.Builder(OutScaner3Activity.this,            android.R.style.Theme_Holo_Light_Dialog).            setTitle("提示").setMessage(message).            setNegativeButton("确定", new DialogInterface.OnClickListener() {        @Override        public void onClick(DialogInterface dialog, int which) {        }    }).setPositiveButton("取消", null);    AlertDialog dialog = builder.create();    dialog.setCanceledOnTouchOutside(false);   //点击AlertDialog外面的位置,AlertDialog不消失,    //设置背景样式    dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);       dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);     dialog.show();    //注意放在dialog.show();的后面    dialog.getButton(DialogInterface.BUTTON_POSITIVE).setFocusable(false);   //获取button    dialog.getButton(DialogInterface.BUTTON_NEGATIVE).setFocusable(false);  //获取button    return dialog;}
阅读全文
0 0