Android 常用的提示框Dialog

BaseDialog

常用的提示框,輸入框,彈窗等

使用方式

build.gradle(project)

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

build.gradle(module app)

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

選擇dialog

在這裏插入圖片描述

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 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 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();

可以輸入內容的確認框

在這裏插入圖片描述

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 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();

在這裏插入圖片描述

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 loadingDialog = new LoadingDialog(this);
loadingDialog.setMessage("loading");
loadingDialog.show();

密碼輸入dialog

在這裏插入圖片描述

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();

在這裏插入圖片描述

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();

github地址https://github.com/HanHuoBin/BaseDialog

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章