lmw
2023-06-06 7a563b559c48b9b339784c25fc5f0adc2ab5154e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package cn.sinata.xldutils.utils
 
import android.app.Activity
import android.app.AlertDialog
import android.content.DialogInterface
import android.text.TextUtils
 
/**
 * alert弹窗
 */
fun Activity.alertDialog(title:String="请注意", message: String, outCancel:Boolean = true, positive:String = "确定", negative:String? = null,
                         pListener: DialogInterface.OnClickListener? = null, nListener:DialogInterface.OnClickListener? = null) {
    val builder = AlertDialog.Builder(this)
    builder.setTitle(title)
    builder.setMessage(message)
    builder.setCancelable(outCancel)
    if (!TextUtils.isEmpty(positive)) {
        builder.setPositiveButton(positive, pListener)
    }
    if (!TextUtils.isEmpty(negative)) {
        builder.setNegativeButton(negative, nListener)
    }
    builder.create().show()
}