开源地址

https://github.com/HanHuoBin/BaseDialog

引入步骤

  1. 项目 build.gradle 添加配置

    1
    2
    3
    4
    5
    6
    allprojects {
    repositories {
    ...
    maven { url 'https://jitpack.io' }
    }
    }
  2. app/build.gradle

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

示例

处理中提示框

image-20210831153934361
1
2
3
LoadingDialog loadingDialog = new LoadingDialog(this);
loadingDialog.setMessage("处理中...");
loadingDialog.show();

弹出选择框

image-20210831154739519
1
2
3
4
5
6
7
8
9
10
11
12
13
ActionSheetDialog dialog = new ActionSheetDialog(this).builder().setTitle("请选择")
.addSheetItem("相册", null, new ActionSheetDialog.OnSheetItemClickListener() {
@Override
public void onClick(int which) {
Toast.makeText(LoginActivity.this, "相册", Toast.LENGTH_LONG).show();
}
}).addSheetItem("拍照", null, new ActionSheetDialog.OnSheetItemClickListener() {
@Override
public void onClick(int which) {
Toast.makeText(LoginActivity.this, "拍照", Toast.LENGTH_LONG).show();
}
});
dialog.show();

确认提示框

image-20210831154503236
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
MyAlertDialog myAlertDialog = new MyAlertDialog(this).builder()
.setTitle("确认吗?")
.setMsg("删除内容")
.setPositiveButton("确认", new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(LoginActivity.this, "确认", Toast.LENGTH_LONG).show();
}
}).setNegativeButton("取消", new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(LoginActivity.this, "取消", Toast.LENGTH_LONG).show();
}
});
myAlertDialog.show();

输入框

image-20210831154256807
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
final MyAlertInputDialog myAlertInputDialog = new MyAlertInputDialog(this).builder()
.setTitle("请输入")
.setEditText("");
myAlertInputDialog.setPositiveButton("确认", new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(LoginActivity.this, myAlertInputDialog.getResult(), Toast.LENGTH_LONG).show();
myAlertInputDialog.dismiss();
}
}).setNegativeButton("取消", new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(LoginActivity.this, "取消", Toast.LENGTH_LONG).show();
myAlertInputDialog.dismiss();
}
});
myAlertInputDialog.show();

密码输入框

image-20210831153814636
1
2
3
4
5
6
7
8
9
10
11
final MyPwdInputDialog pwdDialog = new MyPwdInputDialog(this)
.builder()
.setTitle("请输入密码");
pwdDialog.setPasswordListener(new MyPwdInputDialog.OnPasswordResultListener() {
@Override
public void onPasswordResult(String password) {
Toast.makeText(LoginActivity.this, "您的输入结果:" + password, Toast.LENGTH_LONG).show();
pwdDialog.dismiss();
}
});
pwdDialog.show();

支付密码输入框

image-20210831152929495
1
2
3
4
5
6
7
8
9
final MyPayInputDialog myPayInputDialog = new MyPayInputDialog(this).Builder();
myPayInputDialog.setResultListener(new MyPayInputDialog.ResultListener() {
@Override
public void onResult(String result) {
Toast.makeText(LoginActivity.this, "您的输入结果:" + result, Toast.LENGTH_LONG).show();
myPayInputDialog.dismiss();
}
}).setTitle("支付");
myPayInputDialog.show();