List of usage examples for android.app AlertDialog.Builder setTitle
@Override public void setTitle(CharSequence title)
From source file:net.openwatch.acluaz.FormFragmentActivity.java
private void showFormIncompleteDialog() { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(getString(R.string.form_incomplete_dialog_title)) .setMessage(getString(R.string.form_incomplete_dialog_msg)) .setPositiveButton(getString(R.string.dialog_ok), new OnClickListener() { @Override/*from www .ja v a 2 s .c om*/ public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }).show(); }
From source file:edu.cmu.cs.cloudlet.android.CloudletActivity.java
private void showDialogSelectApp(final String[] applications) { // Show Dialog AlertDialog.Builder ab = new AlertDialog.Builder(this); ab.setTitle("Application List"); ab.setIcon(R.drawable.ic_launcher);//www.j av a 2 s . c o m ab.setSingleChoiceItems(applications, 0, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int position) { selectedOveralyIndex = position; } }).setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int position) { if (position >= 0) { selectedOveralyIndex = position; } else if (applications.length > 0 && selectedOveralyIndex == -1) { selectedOveralyIndex = 0; } String application = applications[selectedOveralyIndex]; runStandAlone(application); } }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int position) { return; } }); ab.show(); }
From source file:br.liveo.ndrawer.ui.fragment.MainFragment.java
private void enableGPS() { AlertDialog.Builder dialog = new AlertDialog.Builder(getActivity()); dialog.setTitle(" (GPS) "); dialog.setMessage(/*from www.j av a 2 s . c o m*/ "?? (GPS) . (GPS) ? ?"); dialog.setPositiveButton("", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Intent enableGPSIntent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); startActivityForResult(enableGPSIntent, 1); } }).setNegativeButton("", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { return; } }).create().show(); }
From source file:com.zapto.park.ParkActivity.java
public AlertDialog makeAlertDialog(String title, String message) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(title) //.setIcon(android.R.drawable.stat_sys_warning) .setMessage(message).setCancelable(true).setPositiveButton(android.R.string.ok, null); /*.setNegativeButton(R.string.learn_more, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(Intent.ACTION_VIEW, helpUri); startActivity(intent);//from www .j a v a2 s. c o m } });*/ return builder.create(); }
From source file:edu.cmu.cs.cloudlet.android.CloudletActivity.java
private void showDialogSelectOverlay(final ArrayList<VMInfo> vmList) { String[] nameList = new String[vmList.size()]; for (int i = 0; i < nameList.length; i++) { nameList[i] = new String(vmList.get(i).getAppName()); }//w ww. j av a2s . c om AlertDialog.Builder ab = new AlertDialog.Builder(this); ab.setTitle("Overlay List"); ab.setIcon(R.drawable.ic_launcher); ab.setSingleChoiceItems(nameList, 0, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int position) { selectedOveralyIndex = position; } }).setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int position) { if (position >= 0) { selectedOveralyIndex = position; } VMInfo overlayVM = vmList.get(selectedOveralyIndex); runConnection(CLOUDLET_SYNTHESIS_IP, CLOUDLET_SYNTHESIS_PORT, overlayVM); } }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int position) { return; } }); ab.show(); }
From source file:edu.stanford.mobisocial.dungbeetle.ui.fragments.FeedActionsFragment.java
public void broadcastGps() { final CharSequence[] items = { "5 minutes", "15 minutes", "1 hour", " 24 hours" }; AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle("Choose duration of broadcast"); builder.setItems(items, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, final int item) { AlertDialog.Builder alert = new AlertDialog.Builder(getActivity()); alert.setMessage("Enter a secret key if you want to:"); final EditText input = new EditText(getActivity()); alert.setView(input);//from w w w . ja va2s . c om alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { final String password = input.getText().toString(); myLocation = new MyLocation(); locationResult = new MyLocation.LocationResult() { final ProgressDialog dialog = ProgressDialog.show(getActivity(), "", "Preparing broadcast...", true); @Override public void gotLocation(final Location location) { //Got the location! try { int minutes; if (item == 0) { minutes = 5; } else if (item == 1) { minutes = 15; } else if (item == 2) { minutes = 60; } else if (item == 3) { minutes = 1440; } else { minutes = 5; } Uri uri = new Uri.Builder().scheme("http").authority("suif.stanford.edu") .path("dungbeetle/nearby.php").build(); StringBuffer sb = new StringBuffer(); DefaultHttpClient client = new DefaultHttpClient(); HttpPost httpPost = new HttpPost(uri.toString()); List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2); nameValuePairs.add(new BasicNameValuePair("group_name", mGroupName)); nameValuePairs .add(new BasicNameValuePair("feed_uri", mExternalFeedUri.toString())); nameValuePairs.add(new BasicNameValuePair("length", Integer.toString(minutes))); nameValuePairs.add( new BasicNameValuePair("lat", Double.toString(location.getLatitude()))); nameValuePairs.add(new BasicNameValuePair("lng", Double.toString(location.getLongitude()))); nameValuePairs.add(new BasicNameValuePair("password", password)); httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); try { HttpResponse execute = client.execute(httpPost); InputStream content = execute.getEntity().getContent(); BufferedReader buffer = new BufferedReader(new InputStreamReader(content)); String s = ""; while ((s = buffer.readLine()) != null) { sb.append(s); } } catch (Exception e) { e.printStackTrace(); } String response = sb.toString(); if (response.equals("1")) { Toast.makeText(getActivity(), "Now broadcasting for " + items[item], Toast.LENGTH_SHORT).show(); } else Log.w(TAG, "Wtf"); Log.w(TAG, "response: " + response); } catch (Exception e) { } dialog.dismiss(); } }; locationClick(); } }); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { } }); alert.show(); } }); AlertDialog alert = builder.create(); alert.show(); }
From source file:it.scoppelletti.mobilepower.app.HelpDialogFragment.java
/** * Crea il dialogo.//from w w w.j a va 2s . c o m * * @param savedInstanceState Stato dell’istanza. * @return Dialogo. */ @Override public Dialog onCreateDialog(Bundle savedInstanceState) { int mode, resId; View contentView; AlertDialog dlg; AlertDialog.Builder builder; LayoutInflater inflater; TextView textControl; Bundle args = getArguments(); builder = newAlertDialogBuilder(); resId = args.getInt(HelpDialogFragment.ARG_TITLEID, 0); if (resId > 0) { builder.setTitle(resId); } inflater = getActivity().getLayoutInflater(); contentView = inflater.inflate(R.layout.helpdialog, null); builder.setView(contentView); builder.setIcon(android.R.drawable.ic_dialog_info); mode = getArguments().getInt(HelpDialogFragment.ARG_MODE, HelpDialogFragment.MODE_HELP); switch (mode) { case HelpDialogFragment.MODE_CONFIRM: setCancelable(false); builder.setCancelable(false); builder.setPositiveButton(R.string.cmd_proceed, this); builder.setNegativeButton(android.R.string.cancel, this); break; default: // HelpDialogFragment.MODE_HELP builder.setNeutralButton(R.string.cmd_close, null); break; } dlg = builder.create(); textControl = (TextView) contentView.findViewById(R.id.txt_help); textControl.setKeyListener(null); resId = args.getInt(HelpDialogFragment.ARG_TEXTID, 0); if (resId > 0) { textControl.setText(Html.fromHtml(getResources().getString(resId))); } return dlg; }
From source file:com.zira.registration.DocumentUploadActivity.java
protected void selectImage() { final CharSequence[] options = { "Take Photo", "Choose from Gallery", "Cancel" }; AlertDialog.Builder builder = new AlertDialog.Builder(DocumentUploadActivity.this); builder.setTitle("Add Photo!"); builder.setItems(options, new DialogInterface.OnClickListener() { @Override/*from www. ja v a2 s . c o m*/ public void onClick(DialogInterface dialog, int item) { if (options[item].equals("Take Photo")) { Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); // Ensure that there's a camera activity to handle the intent if (takePictureIntent.resolveActivity(getPackageManager()) != null) { // Create the File where the photo should go File photoFile = null; try { mCurrentPhotoPath = Util.createImageFile(); photoFile = new File(mCurrentPhotoPath); } catch (Exception ex) { // Error occurred while creating the File ex.printStackTrace(); } // Continue only if the File was successfully created if (photoFile != null) { takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile)); startActivityForResult(takePictureIntent, 1); } } } else if (options[item].equals("Choose from Gallery")) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(Intent.createChooser(intent, "Select Picture"), 2); } else if (options[item].equals("Cancel")) { dialog.dismiss(); } } }); builder.show(); }
From source file:com.getkickbak.plugin.NotificationPlugin.java
/** * Builds and shows a native Android alert with given Strings * /*from w w w.j a va 2s .com*/ * @param message * The message the alert should display * @param title * The title of the alert * @param buttonLabel * The label of the button * @param callbackContext * The callback context */ public synchronized void alert(final String message, final String title, final String buttonLabel, final CallbackContext callbackContext) { final CordovaInterface cordova = this.cordova; Runnable runnable = new Runnable() { public void run() { AlertDialog.Builder dlg = new AlertDialog.Builder(cordova.getActivity()); dlg.setMessage(message); dlg.setTitle(title); dlg.setCancelable(true); dlg.setPositiveButton(buttonLabel, new AlertDialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, 0)); } }); dlg.setOnCancelListener(new AlertDialog.OnCancelListener() { public void onCancel(DialogInterface dialog) { dialog.dismiss(); callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, 0)); } }); dlg.create(); dlg.show(); }; }; this.cordova.getActivity().runOnUiThread(runnable); }
From source file:com.spoiledmilk.ibikecph.favorites.EditFavoriteFragment.java
private void launchErrorDialog(final String msg) { if (getActivity() != null && getView() != null) { getActivity().runOnUiThread(new Runnable() { @Override/*from w w w .j a va 2 s . c om*/ public void run() { getView().findViewById(R.id.progress).setVisibility(View.INVISIBLE); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle("Error"); builder.setMessage(msg); builder.setPositiveButton(IbikeApplication.getString("ok"), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog2 = builder.show(); } }); } }