Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8626075
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:56:13+00:00 2026-06-12T07:56:13+00:00

I know that pre-ICS, the standard order in an AlertDialog is Ok / Cancel

  • 0

I know that pre-ICS, the standard order in an AlertDialog is “Ok” / “Cancel” and that has changed in ICS (the standard order became “Cancel” / “Ok”)

However, even if I use

alert.setButton(AlertDialog.BUTTON_POSITIVE, "Ok", ...)
alert.setButton(AlertDialog.BUTTON_NEGATIVE, "Cancel", ...)

I get the same result running the application in pre-ICS and in ICS: in both the positive option appears at left, negative at right.

Shouldn’t this be automatic, since we are using System constants to define where positive (AlertDialog.BUTTON_POSITIVE) and negative (AlertDialog.BUTTON_NEGATIVE) are?

EDIT:
After accepting the solution, I would like to refer that I am now using the following code to set the buttons in the correct order in ICS and pre-ICS:

if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) { // pre-ICS, show Positive/Negative
    alertDialog.setButton(labelPositive, positiveListener);
    alertDialog.setButton2(labelNegative, negativeListener);    
} else { // ICS+, show Negative/Positive
    alertDialog.setButton(labelNegative, negativeListener);
    alertDialog.setButton2(labelPositive, positiveListener);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T07:56:15+00:00Added an answer on June 12, 2026 at 7:56 am

    I’m not sure what you expect as an answer… The constant values are the same, Android simply switched the wording.

    You probably know that BUTTON_POSITIVE has no mandate that it link to an “affirmative” action. So BUTTON_POSITIVE can have the “Cancel” code as readily as the “Ok” code, in fact they are just constants (positive: -1, neutral: -2, negative: -3).

    Imagine a pre-ICS Dialog with the positive (left) and negative (right) buttons respectively labeled <- and ->. Watch what happens if ICS did automatically switch the values of the existing constants:

            Pre-ICS Dialog          |        Post-ICS Dialog
    --------------------------------|-------------------------------
          | <- |       | -> |       |      | -> |       | <- |
     ie.   "Ok"       "Cancel"      |     "Cancel"       "Ok"     
    

    The buttons no longer make sense…

    In short, ICS would’ve broken existing code in one generation by automatically reordering the buttons. So if the idea that the order of the default labels is not consistent in pre- and post-ICS devices truly bothers you, then consider using their constant values (-1, -2, -3) rather than their aliases.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have an MSI, that has .NET Framework as a pre-requisite. I know
The only pre-process directive that I know about in VBScript / Classic ASP is
I know that Phonegap has an event for back button, but it's only available
I know that this sort of question has been asked here before, but still
I know that when I use range([start], stop[, step]) or slice([start], stop[, step]) ,
I know that the storing of UIImage's in core data has been discussed a
I know that there are several very similarly-related questions on this website, however after
I know that C# 4.0 has the Code Contract feature that can be used
I am trying to use : http://code.google.com/p/jspf/ within a GWT framework. I know that
I know that Java is pre-installed in Mac OS X but i wonder if

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.