自定义简单AlterDialog

来源:互联网 发布:阿斗 知乎 编辑:程序博客网 时间:2024/05/16 09:35

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


自定义AlterDialog效果:

这里写图片描述

1.实现代码:

//创建AlterDialogAlertDialog.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也是可以实现自定义效果。

原创粉丝点击