本文主要是介绍AlertDialog获取Button,点击外围不消失,设置样式,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
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() {@Overridepublic 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); //获取buttondialog.getButton(DialogInterface.BUTTON_NEGATIVE).setFocusable(false); //获取buttonreturn dialog;
}
这篇关于AlertDialog获取Button,点击外围不消失,设置样式的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!