美文网首页IT技术Android 知识点及效果
android 常用的提示框,输入框,弹窗等

android 常用的提示框,输入框,弹窗等

作者: 0ae0738a217e | 来源:发表于2018-07-18 17:48 被阅读6137次

    BaseDialog

    常用的提示框,输入框,弹窗等

    使用方式

    Step 1. Add the JitPack repository to your build file

    Add it in your root build.gradle at the end of repositories:

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

    Step 2. Add the dependency

    dependencies {
       implementation 'com.github.HanHuoBin:BaseDialog:1.2.0'
    }
    

    git地址

    选择dialog

    ![actionsheet.gif](https://img.haomeiwen.com/i7055061/3ffd1be1fd3bf7a4.gif?imageMogr2/auto-orient/strip)

    使用

    ActionSheetDialog dialog = new ActionSheetDialog(this).builder().setTitle("请选择")
            .addSheetItem("相册", null, new ActionSheetDialog.OnSheetItemClickListener() {
                @Override
                public void onClick(int which) {
                    showMsg("相册");
                }
            }).addSheetItem("拍照", null, new ActionSheetDialog.OnSheetItemClickListener() {
                @Override
                public void onClick(int which) {
                    showMsg("拍照");
                }
            });
    dialog.show();
    

    确认dialog

    myalertdialog.gif
    MyAlertDialog myAlertDialog = new MyAlertDialog(this).builder()
            .setTitle("确认吗?")
            .setMsg("删除内容")
            .setPositiveButton("确认", new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    showMsg("确认");
                }
            }).setNegativeButton("取消", new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    showMsg("取消");
                }
            });
    myAlertDialog.show();
    
    confirmdialog.gif
    ConfirmDialog confirmDialog = new ConfirmDialog(this);
    confirmDialog.setLogoImg(R.mipmap.dialog_notice).setMsg("提示");
    confirmDialog.setClickListener(new ConfirmDialog.OnBtnClickListener() {
        @Override
        public void ok() {
    
        }
    
        @Override
        public void cancel() {
    
        }
    });
    confirmDialog.show();
    

    可以输入内容的确认框

    myalertinputdialog.gif
    final MyAlertInputDialog myAlertInputDialog = new MyAlertInputDialog(this).builder()
                    .setTitle("请输入")
                    .setEditText("");
    myAlertInputDialog.setPositiveButton("确认", new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            showMsg(myAlertInputDialog.getResult());
            myAlertInputDialog.dismiss();
        }
    }).setNegativeButton("取消", new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            showMsg("取消");
            myAlertInputDialog.dismiss();
        }
    });
    myAlertInputDialog.show();
    
    

    连接dialog

    myimagemsgdialog.gif
    MyImageMsgDialog myImageMsgDialog = new MyImageMsgDialog(this).builder()
            .setImageLogo(getResources().getDrawable(R.mipmap.ic_launcher))
            .setMsg("连接中...");
    ImageView logoImg = myImageMsgDialog.getLogoImg();
    logoImg.setImageResource(R.drawable.connect_animation);
    connectAnimation = (AnimationDrawable) logoImg.getDrawable();
    connectAnimation.start();
    myImageMsgDialog.show();
    
    connecting.gif
    ConnectingDialog connectingDialog = new ConnectingDialog(this);
    connectingDialog.setMessage("MSG");
    connectingDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialog) {
    
        }
    });
    connectingDialog.setOnKeyListener(new DialogInterface.OnKeyListener() {
        @Override
        public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
            return false;
        }
    });
    connectingDialog.show();
    

    加载dialog

    loadingdialog.gif
    LoadingDialog loadingDialog = new LoadingDialog(this);
    loadingDialog.setMessage("loading");
    loadingDialog.show();
    

    密码输入dialog

    inputpwddialog.gif
    final MyPwdInputDialog pwdDialog = new MyPwdInputDialog(this)
            .builder()
            .setTitle("请输入密码");
    pwdDialog.setPasswordListener(new MyPwdInputDialog.OnPasswordResultListener() {
        @Override
        public void onPasswordResult(String password) {
            showMsg("您的输入结果:" + password);
            pwdDialog.dismiss();
        }
    });
    pwdDialog.show();
    
    paydialog.gif
    final MyPayInputDialog myPayInputDialog = new MyPayInputDialog(this).Builder();
    myPayInputDialog.setResultListener(new MyPayInputDialog.ResultListener() {
        @Override
        public void onResult(String result) {
            showMsg("您的输入结果:" + result);
            myPayInputDialog.dismiss();
        }
    }).setTitle("支付");
    myPayInputDialog.show();
    

    相关文章

      网友评论

        本文标题:android 常用的提示框,输入框,弹窗等

        本文链接:https://www.haomeiwen.com/subject/klkapftx.html