Android Don't dismiss AlertDialog after clicking PositiveButton

后端 未结 5 2052
情歌与酒
情歌与酒 2020-12-12 20:32

Can I just don\'t dismiss my AlertDialog after clicking PositiveButton?

I would like to remain the dialog to show something update on my ArrayAdapter listWords.

5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-12 21:13

    Answer in Kotlin :

    val dialog = AlertDialog.Builder(context)
        .setView(v)
        .setTitle(R.string.my_title)
        .setPositiveButton(android.R.string.ok, null)
        .setNegativeButton(android.R.string.cancel, null)
        .create()
    
    dialog.setOnShowListener {
    
            dialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
                // Apply logic here
            }
    
        }
    

提交回复
热议问题