List of usage examples for android.content DialogInterface cancel
void cancel();
From source file:com.codeskraps.sbrowser.home.SBrowserActivity.java
public void onClick(View v) { switch (v.getId()) { case R.id.btnWww: final AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle(getResources().getString(R.string.alertHttpTitle)); alert.setMessage(getResources().getString(R.string.alertHttpSummary)); final EditText input = new EditText(this); String url = webView == null ? null : webView.getUrl(); if (url != null) input.setText(url);/*from w ww . j a v a 2 s .c o m*/ alert.setView(input); alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String value = input.getText().toString().trim(); if (value.startsWith("http")) webView.loadUrl(value); else webView.loadUrl("http://" + value); } }); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }); alert.show(); break; case R.id.btnHome: webView.loadUrl(sBrowserData.getetxtHome()); break; case R.id.btnRight: webView.goForward(); break; case R.id.btnRefresh: if (wF != null && wF.isReloading() == false) { webView.reload(); } else { webView.stopLoading(); } break; case R.id.btnSearch: doSearch(); break; case R.id.btnMenu: Log.v(TAG, "Menu pressed"); openOptionsMenu(); break; } }
From source file:br.com.GUI.avaliacoes.AvaliarPerimetria.java
public void tirarFoto() { AlertDialog.Builder alertDialog = new AlertDialog.Builder(getActivity()); alertDialog.setTitle("Selecione o mtodo"); alertDialog.setMessage("Deseja usar qual aplicativo para importar sua foto?"); alertDialog.setIcon(R.drawable.profile); alertDialog.setPositiveButton("Camera", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { usarCamera();/* w ww . j ava 2 s . com*/ } }); alertDialog.setNegativeButton("Galeria", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { usarGaleria(); dialog.cancel(); } }); alertDialog.show(); }
From source file:com.mendhak.gpslogger.common.PrefsIO.java
public void AskFileName() { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setTitle(R.string.AskFileName); final EditText input = new EditText(context); input.setInputType(InputType.TYPE_CLASS_TEXT); int pos = curFileName.lastIndexOf(File.separator) + 1; String filename = ""; if (pos > 0) filename = curFileName.substring(pos); pos = filename.lastIndexOf(extension); if (pos > 1) input.setText(filename.substring(0, pos - 1)); else// w w w. j ava 2s .co m input.setText(defFileName); Utilities.LogDebug("Asking user the filename to use for export of settings"); builder.setView(input); builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String str = input.getText().toString(); String fname = ""; if (str.length() > 0) fname = str.replaceAll(filter, ""); if (fname.length() != 0) { curFileName = defPath + File.separator + fname + "." + extension; ExportFile(); } } }); builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); builder.show(); }
From source file:com.safecell.ManageProfile_Activity.java
void displayDialog(String title, String inputText, final int position) { LayoutInflater li = LayoutInflater.from(this); View dialogView = li.inflate(R.layout.dialog_edittext_input, null); dialogInputEditText = (EditText) dialogView.findViewById(R.id.DialogEditTextInputEditText); dialogInputEditText.setText(inputText); dialogInputEditText.setInputType(setInputTypeKeyBoard(position)); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(title).setInverseBackgroundForced(true).setView(dialogView).setCancelable(false) .setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { String text = dialogInputEditText.getText().toString(); if (!text.equalsIgnoreCase("")) { if (position == 2) { if (validationForEmailAddress(text)) { setDialogValuesListArrayAdapter(position); dialog.cancel(); } else { dialog.cancel(); }//from w w w . j a va2 s. com } else { setDialogValuesListArrayAdapter(position); dialog.cancel(); } } else { Toast.makeText(context, "Blank not allowed.", Toast.LENGTH_SHORT).show(); } } }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alert = builder.create(); alert.show(); alert.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); }
From source file:com.example.babycare.fragments.ExampleFragment.java
private void CryingDialogRadio() { final CharSequence[] temperkind = { "", "", "" }; AlertDialog.Builder alt_bld = new AlertDialog.Builder(mContext); alt_bld.setSingleChoiceItems(temperkind, -1, new OnClickListener() { String message;//from w ww .ja va 2 s.c om public void onClick(DialogInterface dialog, int which) { switch (which) { case 0: message = "61"; if (message != null && message.length() > 0) sendMessage(message); break; case 1: message = "62"; if (message != null && message.length() > 0) sendMessage(message); break; case 2: message = "63"; if (message != null && message.length() > 0) sendMessage(message); break; } dialog.cancel(); } }); AlertDialog alert = alt_bld.create(); alert.show(); }
From source file:com.giovanniterlingen.windesheim.view.Fragments.ChooseScheduleFragment.java
private void alertConnectionProblem() { if (!getUserVisibleHint()) { return;//from w w w . j a v a 2 s .co m } ApplicationLoader.runOnUIThread(new Runnable() { @Override public void run() { new AlertDialog.Builder(context).setTitle(getResources().getString(R.string.alert_connection_title)) .setMessage(getResources().getString(R.string.alert_connection_description)) .setPositiveButton(getResources().getString(R.string.connect), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { if (componentFetcher != null) { if (componentFetcher.getStatus() == AsyncTask.Status.RUNNING || componentFetcher.getStatus() == AsyncTask.Status.PENDING) { componentFetcher.cancel(true); } } (componentFetcher = new ComponentFetcher()) .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); dialog.cancel(); } }) .setNegativeButton(getResources().getString(R.string.cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }) .show(); } }); }
From source file:com.esri.arcgisruntime.sample.editfeatureattachments.EditAttachmentActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.attachments); Bundle bundle = getIntent().getExtras(); String s = bundle.getString(getApplication().getString(R.string.attribute)); noOfAttachments = bundle.getInt(getApplication().getString(R.string.noOfAttachments)); // Build a alert dialog with specified style builder = new AlertDialog.Builder(this, R.style.MyAlertDialogStyle); // inflate the floating action button addAttachmentFab = (FloatingActionButton) findViewById(R.id.addAttachmentFAB); // select an image to upload as an attachment addAttachmentFab.setOnClickListener(new View.OnClickListener() { @Override/* w ww . j a va2s . c om*/ public void onClick(View v) { if (!permissionsGranted) { getPermissions(requestCodeGallery); } else { selectAttachment(); } } }); mServiceFeatureTable = new ServiceFeatureTable(getResources().getString(R.string.sample_service_url)); progressDialog = new ProgressDialog(this); // display progress dialog if selected feature has attachments if (noOfAttachments != 0) { progressDialog.setTitle(getApplication().getString(R.string.fetching_attachments)); progressDialog.setMessage(getApplication().getString(R.string.wait)); progressDialog.show(); } else { Toast.makeText(EditAttachmentActivity.this, getApplication().getString(R.string.empty_attachment_message), Toast.LENGTH_LONG).show(); } // inflate the list view list = (ListView) findViewById(R.id.listView); // create custom adapter adapter = new CustomList(EditAttachmentActivity.this, attachmentList); // set custom adapter on the list list.setAdapter(adapter); fetchAttachmentsFromServer(s); // listener on attachment items to download the attachment list.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, final View view, final int position, long id) { listPosition = position; listView = view; if (!permissionsGranted) { getPermissions(requestCodeFolder); } else { fetchAttachmentAsync(position, view); } } }); //set onlong click listener to delete the attachment list.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> arg0, View arg1, final int pos, long id) { builder.setMessage(getApplication().getString(R.string.delete_query)); builder.setCancelable(true); builder.setPositiveButton(getResources().getString(R.string.yes), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { deleteAttachment(pos); dialog.dismiss(); } }); builder.setNegativeButton(getResources().getString(R.string.no), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alert = builder.create(); alert.show(); return true; } }); }
From source file:com.barkside.travellocblog.LocationUpdates.java
@Override public void onResume() { super.onResume(); Log.d(TAG, "onResume"); // If user has turned off location services, there will never be location // event - neither onConnected nor onLocationChanged. Detect that and report to user. if (mUpdatesRequested && !isLocationServiceOn()) { if (mDisplayedServiceOffMessage) { // We display the dialog only once, after that, just a Toast is enough Toast.makeText(this, R.string.no_location_services_message, Toast.LENGTH_SHORT).show(); } else {//from w w w . j a va2 s . c om // First time in, display a warning dialog about turning on location services. mDisplayedServiceOffMessage = true; AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(this.getString(R.string.no_location_services_message)); builder.setTitle(this.getString(R.string.no_location_services_title)); builder.setPositiveButton(R.string.OK, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); builder.setCancelable(true); builder.create().show(); } } }
From source file:fr.mdk.kisspush.KISSPush.java
protected void openAdd() { final Activity act = this; // get prompts.xml view LayoutInflater layoutInflater = getLayoutInflater(); View promptView = layoutInflater.inflate(R.layout.prompts, null); AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(act); // set prompts.xml to be the layout file of the alertdialog // builder/*from w ww. ja v a 2 s . c om*/ alertDialogBuilder.setView(promptView); final EditText input = (EditText) promptView.findViewById(R.id.userInput); // setup a dialog window alertDialogBuilder.setCancelable(false).setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // get user input and set it to // result if (input.getText().toString().length() > 0) { kiss_push_cli.add_alias(input.getText().toString(), new JsonHttpResponseHandler() { @Override public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { getAliases(); } }); } } }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); // create an alert dialog AlertDialog alertD = alertDialogBuilder.create(); alertD.show(); }
From source file:com.g_node.gca.abstracts.EditNoteDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getActivity()); final View view = getActivity().getLayoutInflater().inflate(R.layout.add_note_dialog_fragment, null); final String uuid = getArguments().getString("uuid", "uuid not valid"); final String current_note_id = getArguments().getString("note_id", "note_id not valid"); alertDialogBuilder.setView(view);//from w w w. j a va 2 s. c o m alertDialogBuilder.setTitle("Edit Note: "); final EditText noteTextEditText = (EditText) view.findViewById(R.id.noteText); final EditText noteTitleEditText = (EditText) view.findViewById(R.id.noteTitle2); //setting previous values String getNotesQuery = "SELECT NOTE_ID, ABSTRACT_UUID, NOTE_TITLE, NOTE_TEXT FROM ABSTRACT_NOTES WHERE NOTE_ID = '" + current_note_id + "';"; Cursor notesCursor = DatabaseHelper.database.rawQuery(getNotesQuery, null); notesCursor.moveToFirst(); String currentNoteTitle = notesCursor.getString(notesCursor.getColumnIndexOrThrow("NOTE_TITLE")); String currentNoteText = notesCursor.getString(notesCursor.getColumnIndexOrThrow("NOTE_TEXT")); noteTitleEditText.setText(currentNoteTitle); noteTextEditText.setText(currentNoteText); alertDialogBuilder.setPositiveButton("Update", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String absUUID = uuid; Editable noteText = noteTextEditText.getText(); String y = noteText.toString(); String noteTitle = noteTitleEditText.getText().toString(); DatabaseHelper.updateNoteABSTRACT_NOTES(current_note_id, noteTitle, y); Toast.makeText(getActivity(), "Updated Note - Please Refresh...", Toast.LENGTH_SHORT).show(); // AbstractNotesFragment.adapter.notifyDataSetChanged(); dialog.dismiss(); } }); alertDialogBuilder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Toast.makeText(getActivity(), "Cancelled", Toast.LENGTH_SHORT).show(); dialog.cancel(); } }); return alertDialogBuilder.create(); }