| 注册
请输入搜索内容

热门搜索

Java Linux MySQL PHP JavaScript Hibernate jQuery Nginx
jopen
10年前发布

Android版的SweetAlert

Sweet Alert Dialog

change_type.gif

灵感来源于JS版SweetAlert

如何开始

只显示标题:

new SweetAlertDialog(this)      .setTitleText("Here's a message!")      .show();

显示标题和内容:

new SweetAlertDialog(this)      .setTitleText("Here's a message!")      .setContentText("It's pretty, isn't it?")      .show();

显示异常样式:

new SweetAlertDialog(this, SweetAlertDialog.ERROR_TYPE)      .setTitleText("Oops...")      .setContentText("Something went wrong!")      .show();

显示警告样式:

new SweetAlertDialog(this, SweetAlertDialog.WARNING_TYPE)      .setTitleText("Are you sure?")      .setContentText("Won't be able to recover this file!")      .setConfirmText("Yes,delete it!")      .show();

显示成功完成样式:

new SweetAlertDialog(this, SweetAlertDialog.SUCCESS_TYPE)      .setTitleText("Good job!")      .setContentText("You clicked the button!")      .show();

自定义头部图像:

new SweetAlertDialog(this, SweetAlertDialog.CUSTOM_IMAGE_TYPE)      .setTitleText("Sweet!")      .setContentText("Here's a custom image.")      .setCustomImage(R.drawable.custom_img)      .show();

确认事件绑定:

new SweetAlertDialog(this, SweetAlertDialog.WARNING_TYPE)      .setTitleText("Are you sure?")      .setContentText("Won't be able to recover this file!")      .setConfirmText("Yes,delete it!")      .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() {          @Override          public void onClick(SweetAlertDialog sDialog) {              sDialog.dismiss();          }      })      .show();

显示取消按钮及事件绑定:

new SweetAlertDialog(this, SweetAlertDialog.WARNING_TYPE)      .setTitleText("Are you sure?")      .setContentText("Won't be able to recover this file!")      .setCancelText("No,cancel plx!")      .setConfirmText("Yes,delete it!")      .showCancelButton(true)      .setCancelClickListener(new SweetAlertDialog.OnSweetClickListener() {          @Override          public void onClick(SweetAlertDialog sDialog) {              sDialog.dismiss();          }      })      .show();

确认后切换对话框样式:

new SweetAlertDialog(this, SweetAlertDialog.WARNING_TYPE)      .setTitleText("Are you sure?")      .setContentText("Won't be able to recover this file!")      .setConfirmText("Yes,delete it!")      .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() {          @Override          public void onClick(SweetAlertDialog sDialog) {              sDialog                  .setTitleText("Deleted!")                  .setContentText("Your imaginary file has been deleted!")                  .setConfirmText("OK")                  .setConfirmClickListener(null)                  .changeAlertType(SweetAlertDialog.SUCCESS_TYPE);          }      })      .show();

项目主页:http://www.open-open.com/lib/view/home/1414477866934

 本文由用户 jopen 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
 转载本站原创文章,请注明出处,并保留原始链接、图片水印。
 本站是一个以用户分享为主的开源技术平台,欢迎各类分享!
 本文地址:https://www.open-open.com/lib/view/open1414477866934.html
Android开发 移动开发 SweetAlert