private void DialogSimple(){
AlertDialog.Builder alt_bld = new AlertDialog.Builder(this);
alt_bld.setMessage("Do you want to close this window ?").setCancelable(
false).setPositiveButton("Yes",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// Action for 'Yes' Button
}
}).setNegativeButton("No",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// Action for 'NO' Button
dialog.cancel();
}
});
AlertDialog alert = alt_bld.create();
// Title for AlertDialog
alert.setTitle("Title");
// Icon for AlertDialog
alert.setIcon(R.drawable.icon);
alert.show();
}
(6) Time Picker ½Ã°£¼±Åà ÄÁÆ®·ÑÀ» ´ÙÀ̾ó·Î±×¿¡ ±¸Çö
private void DialogDatePicker(){
Calendar c = Calendar.getInstance();
int cyear = c.get(Calendar.YEAR);
int cmonth = c.get(Calendar.MONTH);
int cday = c.get(Calendar.DAY_OF_MONTH);
DatePickerDialog.OnDateSetListener mDateSetListener =
new DatePickerDialog.OnDateSetListener() {
// onDateSet method
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
String date_selected = String.valueOf(monthOfYear+1)+
" /"+String.valueOf(dayOfMonth)+" /"+String.valueOf(year);
Toast.makeText(DialogSample.this,
"Selected Date is ="+date_selected, Toast.LENGTH_SHORT).show();
}
};
DatePickerDialog alert = new DatePickerDialog(this, mDateSetListener,
cyear, cmonth, cday);
alert.show();
}
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TAG = getClass().getName();
int length = 7;
mMenuText = new String[length];
mMenuSummary = new String[length];
private void DialogRadio() {
final CharSequence[] PhoneModels = { "iPhone", "Nokia", "Android" };
AlertDialog.Builder alt_bld = new AlertDialog.Builder(this);
alt_bld.setIcon(R.drawable.icon);
alt_bld.setTitle("Select a Phone Model");
alt_bld.setSingleChoiceItems(PhoneModels, -1,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
Toast.makeText(getApplicationContext(), "Phone Model = "
+ PhoneModels[item], Toast.LENGTH_SHORT)
.show();
dialog.cancel();
}
});
AlertDialog alert = alt_bld.create();
alert.show();
}
private void DialogSimple() {
AlertDialog.Builder alt_bld = new AlertDialog.Builder(this);
alt_bld.setMessage("Do you want to close this window ?").setCancelable(false)
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// Action for 'Yes' Button
}
}).setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// Action for 'NO' Button
dialog.cancel();
}
});
AlertDialog alert = alt_bld.create();
// Title for AlertDialog
alert.setTitle("Title");
// Icon for AlertDialog
alert.setIcon(R.drawable.icon);
alert.show();
}
private void DialogTimePicker() {
TimePickerDialog.OnTimeSetListener mTimeSetListener =
new TimePickerDialog.OnTimeSetListener() {
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
Toast.makeText(DialogSample.this, "Time is=" + hourOfDay + ":"
+ minute, Toast.LENGTH_SHORT).show();
}
};
TimePickerDialog alert =
new TimePickerDialog(this, mTimeSetListener, 0, 0, false);
alert.show();
}
private void DialogDatePicker() {
Calendar c = Calendar.getInstance();
int cyear = c.get(Calendar.YEAR);
int cmonth = c.get(Calendar.MONTH);
int cday = c.get(Calendar.DAY_OF_MONTH);
DatePickerDialog.OnDateSetListener mDateSetListener =
new DatePickerDialog.OnDateSetListener() {
// onDateSet method
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
String date_selected = String.valueOf(monthOfYear + 1) + " /"
+ String.valueOf(dayOfMonth) + " /"
+ String.valueOf(year);
Toast.makeText(DialogSample.this, "Selected Date is ="
+ date_selected, Toast.LENGTH_SHORT).show();
}
};
DatePickerDialog alert =
new DatePickerDialog(this, mDateSetListener, cyear, cmonth, cday);
alert.show();
}