List of usage examples for android.app AlertDialog.Builder setTitle
@Override public void setTitle(CharSequence title)
From source file:com.bringcommunications.etherpay.SendActivity.java
private void dsp_txid_and_exit() { /*//from w w w. j a v a2 s . c o m TextView txid_view = (TextView) findViewById(R.id.txid); txid_view.setText(txid); if (auto_pay.equals("true")) { String msg = txid.isEmpty() ? "transaction failed" : "your transaction was sent successfully"; Toast.makeText(context, msg, Toast.LENGTH_LONG).show(); NavUtils.navigateUpFromSameTask(context); this.finish(); } else */ { AlertDialog.Builder builder = new AlertDialog.Builder(this); String title = txid.isEmpty() ? "Error" : "Transaction Sent"; String msg = txid.isEmpty() ? "An error occurred while attempting this transaction -- press OK to continue" : "your transaction was sent successfully -- press OK to continue"; builder.setTitle(title); builder.setMessage(msg); builder.setCancelable(true); builder.setNeutralButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); NavUtils.navigateUpFromSameTask(context); context.finish(); } }); AlertDialog alert = builder.create(); alert.show(); } }
From source file:com.pseudosudostudios.jdd.views.Grid.java
/** * Prompts the user and calls loadGame() */// w w w.ja v a 2 s . c om public void makeNewGame() { hasUsed = false; if (tiles != null) for (Tile[] row : tiles) for (Tile t : row) t.setVisibility(View.INVISIBLE); AlertDialog.Builder build = new AlertDialog.Builder(getContext()); build.setTitle("How many colors?").setCancelable(false); View myView = ((LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE)) .inflate(R.layout.number_colors_input, null); final EditText input = (EditText) myView.findViewById(R.id.colorInputET); final RadioButton easy = (RadioButton) myView.findViewById(R.id.easyRB); final RadioButton medium = (RadioButton) myView.findViewById(R.id.mediumRB); final RadioButton hard = (RadioButton) myView.findViewById(R.id.hardRB); build.setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { try { Grid.numberOfColors = Integer.parseInt(input.getText().toString()); if (numberOfColors < 2) { numberOfColors = 2; Toast.makeText(getContext(), getContext().getString(R.string.too_few_colors), Toast.LENGTH_SHORT).show(); } if (numberOfColors > TileFactory.colors.length) numberOfColors = TileFactory.colors.length; } catch (NumberFormatException e) { Grid.numberOfColors = 6; } if (easy.isChecked()) setDifficulty(Difficulty.EASY); if (medium.isChecked()) setDifficulty(Difficulty.MEDIUM); if (hard.isChecked()) setDifficulty(Difficulty.HARD); Tile.initPaints(); loadNewGame(); invalidate(); // let it draw! } }).setView(myView).show(); }
From source file:com.bwash.bwashcar.activities.CompanyActivity.java
/** * This method shows dialog with given title & message. * Also there is an option to pass onClickListener for positive & negative button. * * @param title - dialog title * @param message - dialog message * @param onPositiveButtonClickListener - listener for positive button * @param positiveText - positive button text * @param onNegativeButtonClickListener - listener for negative button * @param negativeText - negative button text *///from www. j a va 2 s . com protected void showAlertDialog(@Nullable String title, @Nullable String message, @Nullable DialogInterface.OnClickListener onPositiveButtonClickListener, @NonNull String positiveText, @Nullable DialogInterface.OnClickListener onNegativeButtonClickListener, @NonNull String negativeText) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(title); builder.setMessage(message); builder.setPositiveButton(positiveText, onPositiveButtonClickListener); builder.setNegativeButton(negativeText, onNegativeButtonClickListener); mAlertDialog = builder.show(); }
From source file:com.googlecode.android_scripting.facade.ui.NFCBeamTask.java
@TargetApi(Build.VERSION_CODES.GINGERBREAD) @SuppressLint("NewApi") @Override//from www .ja va 2 s .c o m public void onCreate() { super.onCreate(); if (initNFCBeam()) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); if (mTitle != null) { builder.setTitle(mTitle); } // Can't display both a message and items. We'll elect to show the items instead. if (mMessage != null && mItems.isEmpty()) { builder.setMessage(mMessage); } switch (mInputType) { // Add single choice menu items to dialog. case SINGLE_CHOICE: builder.setSingleChoiceItems(getItemsAsCharSequenceArray(), mSelectedItems.iterator().next(), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int item) { mSelectedItems.clear(); mSelectedItems.add(item); } }); break; // Add multiple choice items to the dialog. case MULTI_CHOICE: boolean[] selectedItems = new boolean[mItems.size()]; for (int i : mSelectedItems) { selectedItems[i] = true; } builder.setMultiChoiceItems(getItemsAsCharSequenceArray(), selectedItems, new DialogInterface.OnMultiChoiceClickListener() { @Override public void onClick(DialogInterface dialog, int item, boolean isChecked) { if (isChecked) { mSelectedItems.add(item); } else { mSelectedItems.remove(item); } } }); break; // Add standard, menu-like, items to dialog. case MENU: builder.setItems(getItemsAsCharSequenceArray(), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { Map<String, Integer> result = new HashMap<String, Integer>(); result.put("item", item); dismissDialog(); setResult(result); } }); break; case PLAIN_TEXT: mEditText = new EditText(getActivity()); if (mDefaultText != null) { mEditText.setText(mDefaultText); } mEditText.setInputType(mEditInputType); builder.setView(mEditText); break; case PASSWORD: mEditText = new EditText(getActivity()); mEditText.setInputType(android.text.InputType.TYPE_TEXT_VARIATION_PASSWORD); mEditText.setTransformationMethod(new PasswordTransformationMethod()); builder.setView(mEditText); break; default: // No input type specified. } configureButtons(builder, getActivity()); addOnCancelListener(builder, getActivity()); mDialog = builder.show(); mShowLatch.countDown(); } else { } }
From source file:com.remobile.dialogs.Notification.java
/** * Builds and shows a native Android confirm dialog with given title, message, buttons. * This dialog only shows up to 3 buttons. Any labels after that will be ignored. * The index of the button pressed will be returned to the JavaScript callback identified by callbackId. * * @param message The message the dialog should display * @param title The title of the dialog * @param buttonLabels A comma separated list of button labels (Up to 3 buttons) * @param callbackContext The callback context. *//*w w w. j a v a 2 s .c o m*/ public synchronized void confirm(final String message, final String title, final JSONArray buttonLabels, final CallbackContext callbackContext) { Runnable runnable = new Runnable() { public void run() { AlertDialog.Builder dlg = createDialog(); // new AlertDialog.Builder(this.cordova.getActivity(), AlertDialog.THEME_DEVICE_DEFAULT_LIGHT); dlg.setMessage(message); dlg.setTitle(title); dlg.setCancelable(false); // First button if (buttonLabels.length() > 0) { try { dlg.setNegativeButton(buttonLabels.getString(0), new AlertDialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, 1)); } }); } catch (JSONException e) { } } // Second button if (buttonLabels.length() > 1) { try { dlg.setNeutralButton(buttonLabels.getString(1), new AlertDialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, 2)); } }); } catch (JSONException e) { } } // Third button if (buttonLabels.length() > 2) { try { dlg.setPositiveButton(buttonLabels.getString(2), new AlertDialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, 3)); } }); } catch (JSONException e) { } } dlg.setOnCancelListener(new AlertDialog.OnCancelListener() { public void onCancel(DialogInterface dialog) { dialog.dismiss(); callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, 0)); } }); changeTextDirection(dlg); } ; }; this.cordova.getActivity().runOnUiThread(runnable); }
From source file:com.zira.registration.VehicleInformationActivity.java
public void onBackPressed() { AlertDialog.Builder alert = new AlertDialog.Builder(VehicleInformationActivity.this); alert.setTitle("Please confirm"); alert.setMessage("Are you sure you don't want to save any changes?"); alert.setPositiveButton("Yes", new DialogInterface.OnClickListener() { @Override/* ww w . j a v a 2 s. c om*/ public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub for (int i = 0; i < regActivities.size(); i++) { regActivities.get(i).finish(); } } }); alert.setNegativeButton("Dismiss", null); alert.show(); /*Intent intent = new Intent(VehicleInformationActivity.this,GetProfile.class); intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); startActivity(intent);*/ }
From source file:bizapps.com.healthforusPatient.activity.RegisterActivity.java
public void showErrorDialog(String msg, final boolean isVerify) { AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); // set title//w w w . j a v a 2s . co m alertDialogBuilder.setTitle("Info"); // set dialog message alertDialogBuilder.setMessage(msg).setCancelable(false).setNegativeButton("Okay", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); if (status.equalsIgnoreCase("success") && isVerify) { verifyAccount(); } else { Intent intent = new Intent(RegisterActivity.this, LoginActivity.class); startActivity(intent); finish(); } } }); AlertDialog alertDialog = alertDialogBuilder.create(); alertDialog.show(); }
From source file:org.hfoss.posit.android.functionplugin.reminder.SetReminder.java
private void showAddrPickerDialog() { // Set the current dialog currentDialog = ADDRESS_PICKER_DIALOG_ID; // Set the options in Address Picker Dialog final CharSequence[] items = { "Use Current Location", "Use Find's Location", "Enter Location Name / Landmark Address " }; // Build Address Picker Dialog AlertDialog.Builder addrPickerBuilder = new AlertDialog.Builder(this); addrPickerBuilder.setTitle("Step 2: Choose an address"); addrPickerBuilder.setItems(items, mAddrPickerOnClickListener); // Set Listeners addrPickerBuilder.setOnKeyListener(mBackKeyListener); // Finish the activity when the user presses cancel addrPickerBuilder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { setResult(RESULT_OK);// w w w. ja va 2 s . c o m finish(); } }); // Show Address Picker Dialog addrPickerDialog = addrPickerBuilder.create(); addrPickerDialog.show(); }
From source file:org.hfoss.posit.android.functionplugin.reminder.SetReminder.java
private void showAddrEnterDialog() { // Set the current dialog currentDialog = ADDRESS_ENTER_DIALOG_ID; // Build Address Enter Dialog AlertDialog.Builder addrEnterBuilder = new AlertDialog.Builder(this); addrEnterBuilder.setTitle("Step 3: Enter Location Name / Address"); // Initialize EditText for user to type the desired address addressET = new EditText(this); addressET.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE); addrEnterBuilder.setView(addressET); // Set Listeners addrEnterBuilder.setPositiveButton("Search", mAddrEnterOnClickListner); // Finish the activity when the user presses cancel addrEnterBuilder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { setResult(RESULT_OK);/* www.j av a 2 s . com*/ finish(); } }); addrEnterBuilder.setOnKeyListener(mBackKeyListener); // Show Address Enter Dialog addrEnterDialog = addrEnterBuilder.create(); addrEnterDialog.show(); }
From source file:com.googlecode.android_scripting.facade.AndroidFacade.java
private String getInputFromAlertDialog(final String title, final String message, final boolean password) { final FutureActivityTask<String> task = new FutureActivityTask<String>() { @Override/*from ww w.java2 s . co m*/ public void onCreate() { super.onCreate(); final EditText input = new EditText(getActivity()); if (password) { input.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD); input.setTransformationMethod(new PasswordTransformationMethod()); } AlertDialog.Builder alert = new AlertDialog.Builder(getActivity()); alert.setTitle(title); alert.setMessage(message); alert.setView(input); alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.dismiss(); setResult(input.getText().toString()); finish(); } }); alert.setOnCancelListener(new DialogInterface.OnCancelListener() { public void onCancel(DialogInterface dialog) { dialog.dismiss(); setResult(null); finish(); } }); alert.show(); } }; mTaskQueue.execute(task); try { return task.getResult(); } catch (Exception e) { Log.e("Failed to display dialog.", e); throw new RuntimeException(e); } }