1: 在Android 5.11 上使用 SweetAlertDialog对话框需要添加如下两个依赖:
library-1.6.2和materialish-progress-1.7
如果本地不存在这个两个库,则先下载好,放在app的libs目录下.
添加方法如下:
在app的build.gradle 文件里的dependencies下添加如下
compile(name: 'library-1.6.2', ext: 'aar')
compile(name: 'materialish-progress-1.7', ext: 'aar')
implementation fileTree(include: ['*.jar'], dir: 'libs')
2: 在代码里使用SweetAlertDialog
例如弹出警告框
SweetAlertDialog sweetAlertDialog=new SweetAlertDialog(mainActivity,ERROR_TYPE);
sweetAlertDialog.setContentText("测试对话框");
sweetAlertDialog.setConfirmButton("OK", new SweetAlertDialog.OnSweetClickListener() {
@Override
public void onClick(SweetAlertDialog sweetAlertDialog) {
sweetAlertDialog.dismiss();
}
});
sweetAlertDialog.show(); //记得一定要加上这句,否则不能弹出.