0

I need to create a custom dialog, so I'm doing so as follows:

    private void ShowSetOptions(Activity context, UserOptions userOptions)
    {
        var dialog = new Dialog(context);
        dialog.SetContentView(Resource.Layout.view_set_unset_buttons);
    }

The layout

view_set_unset_buttons

is basically a list of buttons which the user can press.

The trouble is, depending on the the value of userOptions, I don't want to show all the buttons in view_set_unset_buttons.

Is there a way for me to apply logic to the creation of view_set_unset_buttons so that I can hide some of the buttons?

SOLUTION:

The solution is to implement my own Dialog box, as outlined in this answer: How to create a Custom Dialog box in android?

Community
  • 1
  • 1
DaveDev
  • 41,155
  • 72
  • 223
  • 385

2 Answers2

0

From my experience resources are compiled statically, so i don't think they are modifiable once you run the program. Why don't you add the buttons programatically? Instead of specifying in your R file, why don't you create a ListView object dynamically and add it to the dialog? You can use setAdapter function to add the dynamic data you need.

0

You should implement your own Dialog with a custom layout, then define the layout programmatically before showing the dialog. That would be the best practice. Cheers.

user2652394
  • 1,686
  • 1
  • 13
  • 15
  • This is what I needed to do. I used the following as a guideline for implementing the Dialog: http://stackoverflow.com/questions/13341560/how-to-create-a-custom-dialog-box-in-android/13342157#13342157 – DaveDev Aug 08 '13 at 12:51