List of usage examples for android.app AlertDialog.Builder create
public void create()
From source file:it.mb.whatshare.Dialogs.java
/** * Shows a prompt to the user to rename the argument <tt>device</tt>. * //ww w.ja v a 2 s .co m * @param device * the device to be renamed * @param activity * the parent activity */ public static void promptForNewDeviceName(final PairedDevice device, final MainActivity activity) { Handler handler = new Handler(Looper.getMainLooper()); handler.post(new Runnable() { @Override public void run() { DialogFragment prompt = new PatchedDialogFragment() { public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = getBuilder(activity); final EditText input = new EditText(getContext()); input.setInputType(InputType.TYPE_CLASS_TEXT); input.setText(device.name); input.setSelection(device.name.length()); // @formatter:off builder.setTitle(R.string.device_name_chooser_title).setView(input) .setPositiveButton(android.R.string.ok, null); // @formatter:on final AlertDialog alertDialog = builder.create(); alertDialog.setOnShowListener( new DeviceNameChooserPrompt(alertDialog, input, activity, new Callback<String>() { @Override public void run() { // @formatter:off device.rename(getParam()); activity.onSelectedDeviceRenamed(); ((InputMethodManager) activity .getSystemService(Context.INPUT_METHOD_SERVICE)) .hideSoftInputFromWindow(input.getWindowToken(), 0); // @formatter:on } })); return alertDialog; } }; prompt.show(activity.getSupportFragmentManager(), "chooseName"); } }); }
From source file:com.dnielfe.manager.dialogs.DirectoryInfoDialog.java
public Dialog onCreateDialog(final Bundle savedInstanceState) { final Activity activity = this.getActivity(); mView = activity.getLayoutInflater().inflate(R.layout.dialog_directory_info, null); final AlertDialog.Builder builder = new AlertDialog.Builder(activity); builder.setTitle(R.string.dir_info); builder.setView(mView);//w w w . j a v a 2 s. com builder.setNeutralButton(R.string.ok, null); return builder.create(); }
From source file:com.fuzz.android.limelight.model.ChapterTransition.java
public static void getDrawerPosition() { LayoutInflater inflater = LimeLight.getActivity().getLayoutInflater(); View drawerView = inflater.inflate(R.layout.choose_drawer_item, null); AlertDialog.Builder builder = new AlertDialog.Builder(LimeLight.getActivity()); builder.setTitle(R.string.choose_drawer_item); builder.setView(drawerView);/*from w ww . ja v a 2 s . c o m*/ final Spinner positionSpinner = (Spinner) drawerView.findViewById(R.id.positionSpinner); ArrayList<String> items = new ArrayList<String>(); for (int i = 0; i < LimeLight.getDrawerList().getAdapter().getCount(); i++) { items.add(i + ""); } ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(LimeLight.getActivity(), android.R.layout.simple_spinner_dropdown_item, items); positionSpinner.setAdapter(spinnerArrayAdapter); positionSpinner.setSelection(mDrawerItemPosition); builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { mDrawerItemPosition = Integer.valueOf(positionSpinner.getSelectedItem().toString()); } }); builder.setNegativeButton(R.string.cancel, null); builder.create(); builder.show(); }
From source file:com.otaupdater.utils.Utils.java
public static void showProKeyOnlyFeatureDialog(final Context ctx, final DialogCallback callback) { AlertDialog.Builder builder = new AlertDialog.Builder(ctx); builder.setTitle(R.string.prokey_only_feature_title); builder.setMessage(R.string.prokey_only_feature_message); builder.setPositiveButton(R.string.prokey_only_get, new DialogInterface.OnClickListener() { @Override/*from w ww .ja va2 s . c o m*/ public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); Intent i = new Intent(ctx, SettingsActivity.class); i.setAction(SettingsActivity.EXTRA_SHOW_GET_PROKEY_DLG); i.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); ctx.startActivity(i); } }); builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); final AlertDialog dlg = builder.create(); dlg.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { if (callback != null) callback.onDialogShown(dlg); } }); dlg.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { if (callback != null) callback.onDialogClosed(dlg); } }); dlg.show(); }
From source file:edu.usf.cutr.opentripplanner.android.serialization.TripRequest.java
protected void onPostExecute(Long result) { if (progressDialog.isShowing()) { progressDialog.dismiss();//from ww w. j a va 2s. c o m } for (int i = 0; i < responses.length; i++) { if (responses[i] != null && responses[i].getPlan() != null && responses[i].getPlan().getItinerary().get(0) != null) { callback.onTripRequestComplete(SUCCESS); Log.d(TAG, "Response " + i + ": " + SUCCESS); } else { // TODO - handle errors here? if (responses[i] != null && responses[i].getError() != null) { String msg = String.valueOf(responses[i].getError().getId()); AlertDialog.Builder feedback = new AlertDialog.Builder(context); feedback.setTitle("Error Planning Trip"); feedback.setMessage(msg); feedback.setNeutralButton("OK", null); feedback.create().show(); } callback.onTripRequestComplete(FAILURE); Log.e(TAG, "Response " + i + ": " + FAILURE); } } callback.onTripBatchRequestComplete(responses); }
From source file:org.geek.utils.ApplicationUtils.java
/** * Display a standard Ok / Cancel dialog. * @param context The current context./* w ww . j a va 2s .c om*/ * @param icon The dialog icon. * @param title The dialog title. * @param message The dialog message. * @param onYes The dialog listener for the yes button. */ public static void showOkCancelDialog(Context context, int icon, String title, String message, DialogInterface.OnClickListener onYes) { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setCancelable(true); builder.setIcon(icon); builder.setTitle(title); builder.setMessage(message); builder.setInverseBackgroundForced(true); builder.setPositiveButton(context.getResources().getString(R.string.Commons_Ok), onYes); builder.setNegativeButton(context.getResources().getString(R.string.Commons_Cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); AlertDialog alert = builder.create(); alert.show(); }
From source file:ua.naiksoftware.chars.Sender.java
@Override protected void onPreExecute() { Log.d(tag, "onPreExecute begin"); ProgressBar progressBar = new ProgressBar(EngineActivity.CONTEXT); progressBar.setIndeterminate(true);// w ww . j a v a 2 s . co m AlertDialog.Builder builder = new AlertDialog.Builder(EngineActivity.CONTEXT); builder.setCustomTitle(progressBar); builder.setIcon(android.R.drawable.ic_menu_upload); builder.setMessage(R.string.send_record); builder.setCancelable(false); dialog = builder.create(); dialog.show(); Log.d(tag, "onPreExecute end"); }
From source file:com.microsoft.windowsazure.messaging.e2etestapp.MainActivity.java
/** * Creates a dialog and shows it/*w w w. ja v a 2 s . c om*/ * * @param message * The dialog message * @param title * The dialog title */ private void createAndShowDialog(String message, String title) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(message); builder.setTitle(title); builder.create().show(); }
From source file:com.he5ed.lib.cloudprovider.auth.OAuth2Fragment.java
/** * Show authentication error message//from www .jav a 2s . c om */ private void showErrorDialog() { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setMessage(R.string.dialog_message_auth_error); // Create the AlertDialog Dialog dialog = builder.create(); dialog.show(); }
From source file:com.owncloud.android.CrashlogSendActivity.java
@Override protected Dialog onCreateDialog(int id) { if (id == DIALOG_SUBMIT) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(R.string.crashlog_message); builder.setNegativeButton(R.string.crashlog_dont_send_report, this); builder.setPositiveButton(R.string.crashlog_send_report, this); builder.setCancelable(true);/*from ww w . j a v a 2 s . co m*/ builder.setOnCancelListener(this); return builder.create(); } return super.onCreateDialog(id); }