引入依赖
在根目录下的build.gradle里添加依赖
allprojects { repositories { maven { url "https://jitpack.io" } } }
如报出Build was configured to prefer settings repositories over project repositories but repository ‘maven’ was added by build file ‘build.gradle’ 错误,是因为你的gradle版本过高,在项目根目录的settings.gradle里只留下以下代码,即可
rootProject.name = "DialogTest" include ':app'
在app的build.gradle的dependencies添加依赖
// 提示框项目依赖 implementation 'com.github.xuexiangjys:XUI:1.1.9' implementation 'androidx.appcompat:appcompat:1.3.1' implementation 'androidx.recyclerview:recyclerview:1.2.1' implementation 'com.google.android.material:material:1.4.0' implementation 'com.github.bumptech.glide:glide:4.12.0'
代码
DialogLoader.getInstance().showConfirmDialog( myContext, "需要开启权限才能使用此功能", "设置", (dialog, which) -> { //引导用户到设置中去进行设置 Intent intent = new Intent(); intent.setAction("android.settings.APPLICATION_DETAILS_SETTINGS"); intent.setData(Uri.fromParts("package", myContext.getPackageName(), null)); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); dialog.dismiss(); }, "取消", (dialog, which) -> { dialog.dismiss(); } );