Take the 2-minute tour ×

As some of you might have noticed, Android changed the order in which the OK/Cancel buttons are displayed in dialogs after ICS (see this issue). The change might make sense, I'm not contesting it. My question is, how are you guys dealing with applications that support both the new theme (because of the action bar) and the "original" theme? How can we reconcile the order in our layouts with the order in the Dialog?

I tried looking into the dialog code, but it's not doing anything special, the order is determined in the layout files (which is styled different for Holo). Has anyone created a fragment or widget that takes this into account?

share|improve this question
add comment

2 Answers

up vote 7 down vote accepted

You can put an alternative layout in layout-v14 with the buttons positioned as in ICS. In fact, that is what lint will advise you to do when you run it on your project. Quote:

Layout uses the wrong button order for API >= 14: Create a layout-v14/layout.xml file with opposite order: OK button should be on the right (was "OK | Cancel", should be "Cancel | OK")

You can use DialogFragment to create dialogs with custom layouts.

share|improve this answer
add comment

I guess, when you creating AlertDialog, it will place buttons according to current system theme.

share|improve this answer
Of course, but I want to use the same layout in other UIs, e.g. an activity that the user needs to OK/Cancel out of. –  dmon May 2 '12 at 13:55
add comment

Your Answer


