Skip to content

Instantly share code, notes, and snippets.

public class Sta{
}
public class Sta{
}
AlertDialog.Builder builder
= new AlertDialog.Builder(this);
builder.setMessage(“Are you sure you want to exit?”)
.setCancelable(false)
.setPositiveButton(“Yes”,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
MyActivity.this.finish();
}})
.setNegativeButton(“No”, new DialogInterface.OnClickListener() {
AlertDialog.Builder builder
= new AlertDialog.Builder(this);
builder.setMessage(“Are you sure you want to exit?”)
.setCancelable(false)
.setPositiveButton(“Yes”,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
MyActivity.this.finish();
}})
.setNegativeButton(“No”, new DialogInterface.OnClickListener() {
AlertDialog.Builder builder
= new AlertDialog.Builder(this);
builder.setMessage(“Are you sure you want to exit?”)
.setCancelable(false)
.setPositiveButton(“Yes”,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
MyActivity.this.finish();
}})
.setNegativeButton(“No”, new DialogInterface.OnClickListener() {
AlertDialog.Builder builder
= new AlertDialog.Builder(this);
builder.setMessage(“Are you sure you want to exit?”)
.setCancelable(false)
.setPositiveButton(“Yes”,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
MyActivity.this.finish();
}})
.setNegativeButton(“No”, new DialogInterface.OnClickListener() {
AlertDialog.Builder builder
= new AlertDialog.Builder(this);
builder.setMessage(“Are you sure you want to exit?”)
.setCancelable(false)
.setPositiveButton(“Yes”,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
MyActivity.this.finish();
}})
.setNegativeButton(“No”, new DialogInterface.OnClickListener() {
//구현부분
final CharSequence[] items = {"Red", "Green", "Blue"};
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("리스트의 타이틀");
builder.setItems(items, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
Toast.makeText(getApplicationContext(),
items[item], Toast.LENGTH_SHORT).show();
}
final CharSequence[] items = {"Red", "Green", "Blue"};
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Pick a color");
builder.setSingleChoiceItems(items, -1,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
Toast.makeText(getApplicationContext(), items[item],
Toast.LENGTH_SHORT).show();
}
final CharSequence[] items = {"Red", "Green", "Blue"};
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Pick a color");
builder.setSingleChoiceItems(items, -1,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
Toast.makeText(getApplicationContext(), items[item],
Toast.LENGTH_SHORT).show();
}