android开源框架SweetAlertDialog的使用

来源:互联网 发布:淘宝设计店铺 编辑:程序博客网 时间:2024/06/06 02:24

SweetAlertDialog是一种android炫酷的开源框架,相比普通的dialog要美观的许多。

我们要使用开源项目SweetAlertDialog作为Library,首先我们将开源项目导入,新建自己的项目,将开源项目作为自己的Library(方法略)。开源项目地址:http://pan.baidu.com/s/1b9LYPo

1.简单的消息提示效果图如下:


代码:

SweetAlertDialog sweetAlertDialog=new SweetAlertDialog(this);
    sweetAlertDialog.setCancelable(true);
    sweetAlertDialog.setTitleText("这是一个简单的消息提示框");
    sweetAlertDialog.setCanceledOnTouchOutside(true);
    sweetAlertDialog.show();

2.错误提示框,效果如下:


代码:

SweetAlertDialog alertDialog=new  SweetAlertDialog(this, SweetAlertDialog.ERROR_TYPE);
    alertDialog.setTitleText("登录失败");
alertDialog.setContentText("用户名或密码错误").show();

3.成功提示框,效果如下:


代码:

new SweetAlertDialog(this, SweetAlertDialog.SUCCESS_TYPE)
.setTitleText("支付成功")
.setContentText("等待商家接单...").show();

更多种类可自行尝试,谢谢大家的支持!


1 0
原创粉丝点击