AlertDialog - how can I run checks when user hits 'OK'

后端 未结 4 1830
鱼传尺愫
鱼传尺愫 2021-01-13 14:46

For a custom AlertDialog, can I override the positive button to NOT close the dialog? instead I want to run some edit checks and keep the dialog open if my checks fail.

4条回答
  •  渐次进展
    2021-01-13 14:55

    I faced the same issue wherein I was not able to stop dialog from getting dismissed even when the input I wanted to collected in dialog had validation issues. To resolve this issue, I added buttons in the dialog's custom view so that I have better control.

    There does not seem to be clean way of stopping dialog from getting dismissed if you use dialogBuilder's setNeutralButton or setPositiveButton or setNegativeButton.

提交回复
热议问题