views:

181

answers:

2

I have a simple list view with some check boxes in an alert dialog. I need to option to add a select all/none but you can't bring up the menu in an alert dialog, and I want to do this function from a button. From what I've seen any kind of button (positive, neutral, and negative) all close the dialog regardless.

So, is this possible? If no, what alternatives do I have? My last mitigation is to simply create a new view and recreate everything. Is a new view the best solution?

+4  A: 

So, is this possible?

Not from the standard buttons in AlertDialog, AFAIK.

If no, what alternatives do I have?

Here are some:

  1. Don't offer select all/none
  2. Don't use AlertDialog, but use a dialog-themed activity
  3. Don't use AlertDialog, but use some other subclass of Dialog
  4. Your cited option (don't use setAdapter(), but rather create your own View for the dialog contents)
  5. Don't use a Dialog at all, but a ListActivity started via startActivityForResult() (akin to #2, just without worrying about the theme)
CommonsWare
Thank you for the reply and the numerous alternatives :)
Parker
A: 

So, is this possible?

You may try to use the following method to place your custom view on AlertDialog:

android.app.AlertDialog.Builder.setView(View view)

That view can contain your button. Just attach an onClickListener to the button that would operate with your list view.

Arhimed