自定义简单AlterDialog

背景:系统自带的Dialog非常简单不一定能够满足项目的需求,自定义AlterDialog倒是可以导入自定义布局,满足多样化的需求。这里放一个AlterDialog最简单的例子,看后立马上手。


自定义AlterDialog效果:

自定义简单AlterDialog_第1张图片

1.实现代码:

//创建AlterDialog
AlertDialog.Builder alterinfo = new AlertDialog.Builder(mContext);
                alertDialog = alterinfo.create();
//填充布局
 LayoutInflater layoutInflater = LayoutInflater.from(mContext);
                View dialoginflate = layoutInflater.inflate(R.layout.alter_dialog, null, false);
//设置布局并显示
alertDialog.setView(dialoginflate);
                alertDialog.setTitle("修改补偿参数");
                alertDialog.setMessage("修改补偿参数有助于提高称重数据的准确性");
                alertDialog.show();
//取消显示
alertDialog.cancel();

基本使用方法已奉上,按照如下步骤,弹出个自定义AlterDialog是没有问题的,当然用PopWindow也是可以实现自定义效果。

你可能感兴趣的:(android,AlterDialo,自定义view)