0

I have a custom AlertDialog with a bunch of checkboxes. I want to prevent the AlertDialog from closing if none of the checkboxes are selected. Is this possible?

I know I can close momentarily and re-open it, but I would rather not do this as I have some code within the setPositiveButton which I do not want to repeat.

Thanks.

Rhiokai
  • 2,147
  • 5
  • 16
  • 18

2 Answers2

0

I'm assuming you're using a custom view, so disable the OK/Cancel buttons at the bottom. Next you'll need to disable the back button:

@Override
public void onBackPressed() {}

The only thing left is to make sure your dialog fills the screen. If the user clicks beside the box on the parent view the dialog will close.

MaKR
  • 1,882
  • 2
  • 17
  • 29
0
I want to prevent the AlertDialog from closing

Already Posted Answer on SO

OR

Create Custom Dialog to solve the issue.

Community
  • 1
  • 1
moDev
  • 5,248
  • 4
  • 33
  • 63
  • I already have setCancelable to false. My problem is that I want to stop it from closing when the PositiveButton is pressed if the none of the checkboxes are ticked. – Rhiokai Jan 21 '13 at 19:39