LoginSignup
11
9

More than 5 years have passed since last update.

ダイアログのボタンのOSごとの表示順について

Posted at

概要

  • ダイアログに表示されるボタンの表示順がOSごとに違ってたので整理してみました。
  • 誤りなどあったら指摘いただけるとありがたいです。

確認用コード

メインとなるアクティビティのonCreateに以下の記述を追加します。

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        AlertDialog.Builder alertDialog = new AlertDialog.Builder(this);

        alertDialog.setTitle("test");
        alertDialog.setMessage("Sample Message");

        // positiveボタン
        alertDialog.setPositiveButton("OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                Toast.makeText(MainActivity.this, "OK" + which, Toast.LENGTH_SHORT).show();
            }
        });
        // neutralボタン
        alertDialog.setNeutralButton("SKIP", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                Toast.makeText(MainActivity.this, "SKIP" + which, Toast.LENGTH_SHORT).show();
            }
        });
        // negativeボタン
        alertDialog.setNegativeButton("NO", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                Toast.makeText(MainActivity.this, "NO" + which, Toast.LENGTH_SHORT).show();
            }
        });

        alertDialog.show();
    }

表示内容

OS 2.3.7

2_3_7.png

OS 4.3

4_3_2.png

OS 5.0

スクリーンショット 2015-01-29 22.30.10.png

結果

  • ICS以前
Positive Neutral Negative
  • ICS以降
Negative Neutral Positive
  • Lolipop
Neutral Negative Positive

※ICSを境に変更になったのかは人づてに聞いたので、若干自信ありません。。

11
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
9