Skip to content

Instantly share code, notes, and snippets.

@nommy
Created November 15, 2011 04:35
Show Gist options
  • Save nommy/1366155 to your computer and use it in GitHub Desktop.
Save nommy/1366155 to your computer and use it in GitHub Desktop.
android,UI,AlertDialog(3buttons),shortcode version
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