Update alert dialogs in ApiDemos for Material theme
BUG: 17415772 Change-Id: Ifc1de793458f678a3c40b734d5ab08b2eb382f7a
This commit is contained in:
@@ -69,9 +69,11 @@ public class AlertDialogSamples extends Activity {
|
||||
private static final int DIALOG_YES_NO_HOLO_LIGHT_MESSAGE = 11;
|
||||
private static final int DIALOG_YES_NO_DEFAULT_LIGHT_MESSAGE = 12;
|
||||
private static final int DIALOG_YES_NO_DEFAULT_DARK_MESSAGE = 13;
|
||||
private static final int DIALOG_PROGRESS_SPINNER = 14;
|
||||
|
||||
private static final int MAX_PROGRESS = 100;
|
||||
|
||||
|
||||
private ProgressDialog mProgressSpinnerDialog;
|
||||
private ProgressDialog mProgressDialog;
|
||||
private int mProgress;
|
||||
private Handler mProgressHandler;
|
||||
@@ -81,7 +83,6 @@ public class AlertDialogSamples extends Activity {
|
||||
switch (id) {
|
||||
case DIALOG_YES_NO_MESSAGE:
|
||||
return new AlertDialog.Builder(AlertDialogSamples.this)
|
||||
.setIconAttribute(android.R.attr.alertDialogIcon)
|
||||
.setTitle(R.string.alert_dialog_two_buttons_title)
|
||||
.setPositiveButton(R.string.alert_dialog_ok, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int whichButton) {
|
||||
@@ -124,7 +125,6 @@ public class AlertDialogSamples extends Activity {
|
||||
.create();
|
||||
case DIALOG_YES_NO_DEFAULT_LIGHT_MESSAGE:
|
||||
return new AlertDialog.Builder(AlertDialogSamples.this, AlertDialog.THEME_DEVICE_DEFAULT_LIGHT)
|
||||
.setIconAttribute(android.R.attr.alertDialogIcon)
|
||||
.setTitle(R.string.alert_dialog_two_buttons_title)
|
||||
.setPositiveButton(R.string.alert_dialog_ok, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int whichButton) {
|
||||
@@ -137,7 +137,6 @@ public class AlertDialogSamples extends Activity {
|
||||
.create();
|
||||
case DIALOG_YES_NO_DEFAULT_DARK_MESSAGE:
|
||||
return new AlertDialog.Builder(AlertDialogSamples.this, AlertDialog.THEME_DEVICE_DEFAULT_DARK)
|
||||
.setIconAttribute(android.R.attr.alertDialogIcon)
|
||||
.setTitle(R.string.alert_dialog_two_buttons_title)
|
||||
.setPositiveButton(R.string.alert_dialog_ok, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int whichButton) {
|
||||
@@ -150,7 +149,6 @@ public class AlertDialogSamples extends Activity {
|
||||
.create();
|
||||
case DIALOG_YES_NO_LONG_MESSAGE:
|
||||
return new AlertDialog.Builder(AlertDialogSamples.this)
|
||||
.setIconAttribute(android.R.attr.alertDialogIcon)
|
||||
.setTitle(R.string.alert_dialog_two_buttons_msg)
|
||||
.setMessage(R.string.alert_dialog_two_buttons2_msg)
|
||||
.setPositiveButton(R.string.alert_dialog_ok, new DialogInterface.OnClickListener() {
|
||||
@@ -174,7 +172,6 @@ public class AlertDialogSamples extends Activity {
|
||||
.create();
|
||||
case DIALOG_YES_NO_ULTRA_LONG_MESSAGE:
|
||||
return new AlertDialog.Builder(AlertDialogSamples.this)
|
||||
.setIconAttribute(android.R.attr.alertDialogIcon)
|
||||
.setTitle(R.string.alert_dialog_two_buttons_msg)
|
||||
.setMessage(R.string.alert_dialog_two_buttons2ultra_msg)
|
||||
.setPositiveButton(R.string.alert_dialog_ok, new DialogInterface.OnClickListener() {
|
||||
@@ -212,7 +209,6 @@ public class AlertDialogSamples extends Activity {
|
||||
.create();
|
||||
case DIALOG_PROGRESS:
|
||||
mProgressDialog = new ProgressDialog(AlertDialogSamples.this);
|
||||
mProgressDialog.setIconAttribute(android.R.attr.alertDialogIcon);
|
||||
mProgressDialog.setTitle(R.string.select_dialog);
|
||||
mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
|
||||
mProgressDialog.setMax(MAX_PROGRESS);
|
||||
@@ -231,9 +227,27 @@ public class AlertDialogSamples extends Activity {
|
||||
}
|
||||
});
|
||||
return mProgressDialog;
|
||||
case DIALOG_PROGRESS_SPINNER:
|
||||
mProgressSpinnerDialog = new ProgressDialog(AlertDialogSamples.this);
|
||||
mProgressSpinnerDialog.setTitle(R.string.select_dialog);
|
||||
mProgressSpinnerDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
|
||||
mProgressSpinnerDialog.setButton(DialogInterface.BUTTON_POSITIVE,
|
||||
getText(R.string.alert_dialog_hide), new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int whichButton) {
|
||||
|
||||
/* User clicked Yes so do some stuff */
|
||||
}
|
||||
});
|
||||
mProgressSpinnerDialog.setButton(DialogInterface.BUTTON_NEGATIVE,
|
||||
getText(R.string.alert_dialog_cancel), new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int whichButton) {
|
||||
|
||||
/* User clicked No so do some stuff */
|
||||
}
|
||||
});
|
||||
return mProgressSpinnerDialog;
|
||||
case DIALOG_SINGLE_CHOICE:
|
||||
return new AlertDialog.Builder(AlertDialogSamples.this)
|
||||
.setIconAttribute(android.R.attr.alertDialogIcon)
|
||||
.setTitle(R.string.alert_dialog_single_choice)
|
||||
.setSingleChoiceItems(R.array.select_dialog_items2, 0, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int whichButton) {
|
||||
@@ -256,7 +270,6 @@ public class AlertDialogSamples extends Activity {
|
||||
.create();
|
||||
case DIALOG_MULTIPLE_CHOICE:
|
||||
return new AlertDialog.Builder(AlertDialogSamples.this)
|
||||
.setIcon(R.drawable.ic_popup_reminder)
|
||||
.setTitle(R.string.alert_dialog_multi_choice)
|
||||
.setMultiChoiceItems(R.array.select_dialog_items3,
|
||||
new boolean[]{false, true, false, true, false, false, false},
|
||||
@@ -282,35 +295,33 @@ public class AlertDialogSamples extends Activity {
|
||||
}
|
||||
})
|
||||
.create();
|
||||
case DIALOG_MULTIPLE_CHOICE_CURSOR:
|
||||
String[] projection = new String[] {
|
||||
ContactsContract.Contacts._ID,
|
||||
case DIALOG_MULTIPLE_CHOICE_CURSOR:
|
||||
String[] projection = new String[] {
|
||||
ContactsContract.Contacts._ID,
|
||||
ContactsContract.Contacts.DISPLAY_NAME,
|
||||
ContactsContract.Contacts.SEND_TO_VOICEMAIL
|
||||
};
|
||||
Cursor cursor = managedQuery(ContactsContract.Contacts.CONTENT_URI,
|
||||
projection, null, null, null);
|
||||
return new AlertDialog.Builder(AlertDialogSamples.this)
|
||||
.setTitle(R.string.alert_dialog_multi_choice_cursor)
|
||||
.setMultiChoiceItems(cursor,
|
||||
ContactsContract.Contacts.SEND_TO_VOICEMAIL,
|
||||
ContactsContract.Contacts.DISPLAY_NAME,
|
||||
ContactsContract.Contacts.SEND_TO_VOICEMAIL
|
||||
};
|
||||
Cursor cursor = managedQuery(ContactsContract.Contacts.CONTENT_URI,
|
||||
projection, null, null, null);
|
||||
return new AlertDialog.Builder(AlertDialogSamples.this)
|
||||
.setIcon(R.drawable.ic_popup_reminder)
|
||||
.setTitle(R.string.alert_dialog_multi_choice_cursor)
|
||||
.setMultiChoiceItems(cursor,
|
||||
ContactsContract.Contacts.SEND_TO_VOICEMAIL,
|
||||
ContactsContract.Contacts.DISPLAY_NAME,
|
||||
new DialogInterface.OnMultiChoiceClickListener() {
|
||||
public void onClick(DialogInterface dialog, int whichButton,
|
||||
boolean isChecked) {
|
||||
Toast.makeText(AlertDialogSamples.this,
|
||||
"Readonly Demo Only - Data will not be updated",
|
||||
Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
})
|
||||
.create();
|
||||
new DialogInterface.OnMultiChoiceClickListener() {
|
||||
public void onClick(DialogInterface dialog, int whichButton,
|
||||
boolean isChecked) {
|
||||
Toast.makeText(AlertDialogSamples.this,
|
||||
"Readonly Demo Only - Data will not be updated",
|
||||
Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
})
|
||||
.create();
|
||||
case DIALOG_TEXT_ENTRY:
|
||||
// This example shows how to add a custom layout to an AlertDialog
|
||||
LayoutInflater factory = LayoutInflater.from(this);
|
||||
final View textEntryView = factory.inflate(R.layout.alert_dialog_text_entry, null);
|
||||
return new AlertDialog.Builder(AlertDialogSamples.this)
|
||||
.setIconAttribute(android.R.attr.alertDialogIcon)
|
||||
.setTitle(R.string.alert_dialog_text_entry)
|
||||
.setView(textEntryView)
|
||||
.setPositiveButton(R.string.alert_dialog_ok, new DialogInterface.OnClickListener() {
|
||||
@@ -385,6 +396,14 @@ public class AlertDialogSamples extends Activity {
|
||||
mProgressHandler.sendEmptyMessage(0);
|
||||
}
|
||||
});
|
||||
|
||||
/* Display a custom progress bar */
|
||||
Button progressSpinnerButton = (Button) findViewById(R.id.progress_spinner_button);
|
||||
progressButton.setOnClickListener(new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
showDialog(DIALOG_PROGRESS_SPINNER);
|
||||
}
|
||||
});
|
||||
|
||||
/* Display a radio button group */
|
||||
Button radioButton = (Button) findViewById(R.id.radio_button);
|
||||
|
||||
Reference in New Issue
Block a user