-
-
Save bgnori/2601811 to your computer and use it in GitHub Desktop.
android,UI,AlertDialog(3buttons),shortcode version
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.DialogTest; | |
import android.app.Activity; | |
import android.app.AlertDialog; | |
import android.content.DialogInterface; | |
import android.os.Bundle; | |
public class AlertDialogTest2Activity extends Activity { | |
/** Called when the activity is first created. */ | |
@Override | |
public void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.main); | |
// AlertDialogBuilder | |
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); | |
alertDialogBuilder.setTitle("タイトル"); | |
alertDialogBuilder.setMessage("メッセージ"); | |
alertDialogBuilder.setPositiveButton("肯定", | |
new DialogInterface.OnClickListener() { | |
public void onClick(DialogInterface dialog, int which) { | |
} | |
}); | |
alertDialogBuilder.setNeutralButton("中立", | |
new DialogInterface.OnClickListener() { | |
public void onClick(DialogInterface dialog, int which) { | |
} | |
}); | |
alertDialogBuilder.setNegativeButton("否定", | |
new DialogInterface.OnClickListener() { | |
public void onClick(DialogInterface dialog, int which) { | |
} | |
}); | |
// アラートダイアログのキャンセルが可能かどうかを設定 | |
alertDialogBuilder.setCancelable(true); | |
AlertDialog alertDialog = alertDialogBuilder.create(); | |
// アラートダイアログを表示 | |
alertDialog.show(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment