List of usage examples for android.app AlertDialog.Builder setTitle
@Override public void setTitle(CharSequence title)
From source file:tr.com.turkcellteknoloji.turkcellupdater.UpdaterDialogManager.java
/** * Creates a dialog for given message./* w w w .j a v a2 s . c o m*/ * * @param activity * Parent activity. * @param message * Message contents * @param dismissListener * Listener that will be called when dialog is closed or * cancelled. * @return Created dialog. */ public static Dialog createMessageDialog(Activity activity, Message message, OnDismissListener dismissListener) { final AlertDialog.Builder builder = new AlertDialog.Builder(activity); final String title = message.description == null ? null : message.description.get(MessageDescription.KEY_TITLE); if (!Utilities.isNullOrEmpty(title)) { builder.setTitle(title); } final View dialogContentsView = createMessageDialogContentsView(activity, message.description); builder.setView(dialogContentsView); initializeMessageDialogButtons(activity, builder, message); builder.setCancelable(true); final AlertDialog dialog = builder.create(); if (Utilities.isNullOrEmpty(title)) { dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE); } dialog.setOnDismissListener(dismissListener); return dialog; }
From source file:nf.frex.android.FrexActivity.java
public static void showYesNoDialog(Context context, int titleId, String message, DialogInterface.OnClickListener yesListener, DialogInterface.OnClickListener noListener, DialogInterface.OnCancelListener cancelListener) { TextView textView = new TextView(context); textView.setSingleLine(false);/*w w w . j a va2 s . c o m*/ textView.setPadding(10, 10, 10, 10); textView.setText(message); AlertDialog.Builder b = new AlertDialog.Builder(context); b.setTitle(titleId); b.setView(textView); b.setCancelable(true); if (yesListener != null) { b.setPositiveButton(android.R.string.yes, yesListener); } if (noListener != null) { b.setNegativeButton(android.R.string.no, noListener); } if (cancelListener != null) { b.setOnCancelListener(cancelListener); } b.show(); }
From source file:it.mb.whatshare.Dialogs.java
/** * Shows a dialog to get a name for the inbound device being paired and * starts a new {@link CallGooGlInbound} action if the chosen name is valid. * // ww w . j av a 2s .com * @param deviceType * the model of the device being paired as suggested by the * device itself * @param sharedSecret * the keys used when encrypting the message between devices * @param activity * the caller activity */ public static void promptForInboundName(final String deviceType, final int[] sharedSecret, 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(deviceType); input.setSelection(deviceType.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 new CallGooGlInbound(activity, getParam(), deviceType) .execute(sharedSecret); ((InputMethodManager) activity .getSystemService(Context.INPUT_METHOD_SERVICE)) .hideSoftInputFromWindow(input.getWindowToken(), 0); // @formatter:on } })); return alertDialog; } }; prompt.show(activity.getSupportFragmentManager(), "chooseName"); } }); }
From source file:MainActivity.java
public void confirmDelete(View view) { // String[] countries = new String[]{"China", "France", "Germany", "India", "Russia", "United Kingdom", "United States"}; // ListAdapter countryAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, countries); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Delete") //.setIcon(R.mipmap.ic_launcher) .setMessage("Are you sure you?") // .setAdapter(countryAdapter, new DialogInterface.OnClickListener() { // @Override // public void onClick(DialogInterface dialog, int which) { // Toast.makeText(MainActivity.this, countries[which] + " clicked", Toast.LENGTH_SHORT).show(); // } // }) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Toast.makeText(MainActivity.this, "OK Pressed", Toast.LENGTH_SHORT).show(); }// ww w .jav a2 s. c o m }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Toast.makeText(MainActivity.this, "Cancel Pressed", Toast.LENGTH_SHORT).show(); } }); builder.create().show(); }
From source file:it.mb.whatshare.Dialogs.java
/** * Shows a prompt to the user to rename the argument <tt>device</tt>. * //from w w w . j a va 2s. c o 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.mobage.air.extension.AlertDialog_show.java
@Override public FREObject call(final FREContext context, FREObject[] args) { ArgsParser parser = new ArgsParser(args); HashMap<String, String> opts = parser.nextKeyValueMap(); final String onClickId = parser.nextString(); @SuppressWarnings("unused") final String onErrorId = parser.nextString(); parser.finish();/*from w w w. j a v a 2s . c om*/ AlertDialog.Builder builder = new AlertDialog.Builder(context.getActivity()); builder.setTitle(opts.get("title")); builder.setMessage(opts.get("message")); builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { JSONArray args = new JSONArray(); args.put(which); Dispatcher.dispatch(context, onClickId, args); } }); builder.show(); return null; }
From source file:it.evilsocket.dsploit.core.System.java
public static boolean checkNetworking(final Activity current) { if (Network.isWifiConnected(mContext) == false) { AlertDialog.Builder builder = new AlertDialog.Builder(current); builder.setCancelable(false);/*w ww .j av a 2 s . c o m*/ builder.setTitle("Error"); builder.setMessage("WiFi connectivity went down."); builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); Bundle bundle = new Bundle(); bundle.putBoolean(WifiScannerActivity.CONNECTED, false); Intent intent = new Intent(); intent.putExtras(bundle); current.setResult(Activity.RESULT_OK, intent); current.finish(); } }); AlertDialog alert = builder.create(); alert.show(); return false; } return true; }
From source file:com.lovejoy777sarootool.rootool.dialogs.UnpackDialog.java
@Override public Dialog onCreateDialog(Bundle state) { final Activity a = getActivity(); // Set an EditText view to get user input final EditText inputf = new EditText(a); inputf.setHint(R.string.enter_name); inputf.setText(BrowserActivity.getCurrentlyDisplayedFragment().mCurrentPath + "/"); final AlertDialog.Builder b = new AlertDialog.Builder(a); b.setTitle(R.string.extractto); b.setView(inputf);/*from w ww. j av a2s .c om*/ b.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String newpath = inputf.getText().toString(); dialog.dismiss(); if (ext.equals("zip")) { final UnZipTask task = new UnZipTask(a); task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, file.getPath(), newpath); } else if (ext.equals("rar")) { final UnRarTask task = new UnRarTask(a); task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, file.getPath(), newpath); } } }); b.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); return b.create(); }
From source file:com.dnielfe.manager.dialogs.UnpackDialog.java
@Override public Dialog onCreateDialog(Bundle state) { final Activity a = getActivity(); // Set an EditText view to get user input final EditText inputf = new EditText(a); inputf.setHint(R.string.enter_name); inputf.setText(Browser.mCurrentPath); final AlertDialog.Builder b = new AlertDialog.Builder(a); b.setTitle(R.string.extractto); b.setView(inputf);// w w w. ja v a 2s .co m b.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String newpath = inputf.getText().toString(); dialog.dismiss(); if (ext.equals("zip")) { final UnZipTask task = new UnZipTask(a); task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, file.getPath(), newpath); } else if (ext.equals("rar")) { final UnRarTask task = new UnRarTask(a); task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, file.getPath(), newpath); } } }); b.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); return b.create(); }
From source file:jp.ne.sakura.kkkon.android.exceptionhandler.DefaultUploaderWeb.java
public static AlertDialog.Builder setupAlertDialog(final Context context) { final AlertDialog.Builder alertDialog = new AlertDialog.Builder(context); final Locale defaultLocale = Locale.getDefault(); String title = ""; String message = ""; String positive = ""; String negative = ""; boolean needDefaultLang = true; if (null != defaultLocale) { if (defaultLocale.equals(Locale.JAPANESE) || defaultLocale.equals(Locale.JAPAN)) { title = ""; message = "???????"; positive = "?"; negative = ""; needDefaultLang = false;/*from w w w . jav a 2 s .co m*/ } } if (needDefaultLang) { title = "INFO"; message = "Now uploading error information. Cancel upload?"; positive = "Wait"; negative = "Cancel"; } alertDialog.setTitle(title); alertDialog.setMessage(message); alertDialog.setPositiveButton(positive, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface di, int i) { if (null != thread) { if (thread.isAlive()) { alertDialog.show(); } else { terminate(); } } } }); alertDialog.setNegativeButton(negative, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface di, int i) { if (null != thread) { if (thread.isAlive()) { Log.d(TAG, "request interrupt"); terminate(); } else { // nothing terminate(); } } } }); alertDialog.setCancelable(false); return alertDialog; }