本网站(662p.com)打包出售,且带程序代码数据,662p.com域名,程序内核采用TP框架开发,需要联系扣扣:2360248666 /wx:lianweikj
精品域名一口价出售:1y1m.com(350元) ,6b7b.com(400元) , 5k5j.com(380元) , yayj.com(1800元), jiongzhun.com(1000元) , niuzen.com(2800元) , zennei.com(5000元)
需要联系扣扣:2360248666 /wx:lianweikj
可在Android应用中使用的材料警报对话框
冷月葬花魂 · 854浏览量 · 发布于2019-05-23 +关注

作者TutorialsAndroid,源码KAlertDialog,AlertDialog for Android,一个美丽的材料警报对话框,可在Android应用中使用。

屏幕截图

注意

新版本的15.4.19 requireAPINew版本不支持旧的Android版本。


建立

使用AlertDialog的最简单方法是将库添加为构建的依赖项。

完整

将其添加到存储库末尾的根build.gradle中:

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}

添加依赖项:

dependencies {
        implementation 'com.github.TutorialsAndroid:KAlertDialog:v15.4.19'
}

使用

显示材料进度

KAlertDialog pDialog = new KAlertDialog(this, KAlertDialog.PROGRESS_TYPE);
pDialog.getProgressHelper().setBarColor(Color.parseColor("#A5DC86"));
pDialog.setTitleText("Loading");
pDialog.setCancelable(false);
pDialog.show();

您可以使用物质进度方法通过KAlertDialog.getProgressHelper动态自定义进度条:

  • resetCount()

  • isSpinning()

  • spin()

  • stopSpinning()

  • getProgress()

  • setProgress(float progress)

  • setInstantProgress(float progress)

  • getCircleRadius()

  • setCircleRadius(int circleRadius)

  • getBarWidth()

  • setBarWidth(int barWidth)

  • getBarColor()

  • setBarColor(int barColor)

  • getRimWidth()

  • setRimWidth(int rimWidth)

  • getRimColor()

  • setRimColor(int rimColor)

  • getSpinSpeed()

  • setSpinSpeed(float spinSpeed)

基本信息:

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

带有文字的标题:

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

错误信息:

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

警告信息:

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

成功信息:

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

带有自定义图标的消息:

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

绑定监听器确认按钮:

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

显示取消按钮并将监听器绑定到它:

new KAlertDialog(this, KAlertDialog.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 KAlertDialog.KAlertClickListener() {
        @Override
        public void onClick(KAlertDialog sDialog) {
            sDialog.cancel();
        }
    })
    .show();

自定义警报对话框:

.confirmButtonColor(R.color.colorPrimary) // you can change the color of confirm button
.cancelButtonColor(R.color.colorAccent) // you can change the color of cancel button

如果想用颜色更改按钮角,创建一个可绘制文件:

    
                                                                                                                                                        

然后在创建drawable时调用此方法:

  .confirmButtonColor(R.drawable.button_background) // you can change border and color of button

如果要隐藏警告对话框的标题文本和内容文本:

.setTitleText("Are you sure?") //just don't write this line if you want to hide title text
.setContentText("Won't be able to recover this file!") // don't write this line if you want to hide content text

确认后更改对话框样式:

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

源码使用过程中,如无法搭建或有增加其他功能需求,可联系QQ:236-0248-666 ,付费搭建安装修改服务!
温馨提示:网站源码只作为学习或研究使用,如需商业使用请购买正版!

相关推荐

自定义的Diaolg 安卓源码

相关信息 kenrry1992 · 720浏览 · 2019-11-11 14:16:44
Android 模仿QQ,微信聊天界面长按提示框

相关信息 冷月葬花魂 · 725浏览 · 2019-10-23 10:19:04
一个常用的自定义弹框封装 安卓

相关信息 kenrry1992 · 493浏览 · 2019-10-21 14:53:20
一个可扩展的回收站视图控件 Android源码

相关信息 冷月葬花魂 · 555浏览 · 2019-10-17 11:30:28
弹簧效果的弹出框 安卓源码

相关信息 冷月葬花魂 · 476浏览 · 2019-09-05 15:33:57
用户指引提示视图 安卓源码

相关信息 kenrry1992 · 561浏览 · 2019-08-20 16:45:28
Andorid任意界面悬浮窗,实现悬浮窗如此简单

相关信息 冷月葬花魂 · 1268浏览 · 2019-06-26 14:15:23
Android交互优雅的通用弹窗源码案例

相关信息 匿名 · 835浏览 · 2019-04-19 17:08:53
加载中

0评论

评论
  • 源码信息
  • 所需 0 点数
  • 源码作者:匿名作者
  • 源码大小:15.711 MB
  • 源码类型:android源码
  • 显示语言: 简体中文
  • 运行环境:未知
分类专栏
小鸟云服务器
扫码进入手机网页