public void showGagne(View view) { AlertDialog.Builder builder = new AlertDialog.Builder(this); end = System.currentTimeMillis(); elapsed = (end - start) / 1000; builder .setTitle(R.string.gagne) .setMessage("Vous avez gagné en " + elapsed + " secondes") .setPositiveButton( R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { finish(); } }) .setNegativeButton( R.string.restart, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { restart(); } }); AlertDialog dialog = builder.create(); dialog.show(); }
private void buildAlertMessageNoGps() { final AlertDialog.Builder builder = new AlertDialog.Builder(this); builder .setMessage(" GPS & LOCATIONSERVICE is Required, do you want to enable it?") .setCancelable(false) .setPositiveButton( "Yes", new DialogInterface.OnClickListener() { public void onClick( @SuppressWarnings("unused") final DialogInterface dialog, @SuppressWarnings("unused") final int id) { startActivity( new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS)); } }) .setNegativeButton( "No", new DialogInterface.OnClickListener() { public void onClick( final DialogInterface dialog, @SuppressWarnings("unused") final int id) { dialog.cancel(); } }); final AlertDialog alert = builder.create(); alert.show(); }
public final void showYesNoCancelBox(String title, String message, final long callback) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder .setTitle(title) .setMessage(message) .setCancelable(true) .setPositiveButton( "Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); JuceAppActivity.this.alertDismissed(callback, 1); } }) .setNegativeButton( "No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); JuceAppActivity.this.alertDismissed(callback, 2); } }) .setNeutralButton( "Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); JuceAppActivity.this.alertDismissed(callback, 0); } }); builder.create().show(); }
public void showEditDialog( Context context, String hintText, String OKText, final DialogCallBack callBack) { final EditText et_search; AlertDialog.Builder dialog = new AlertDialog.Builder(context); LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); LinearLayout layout = (LinearLayout) inflater.inflate(R.layout.dialog_view, null); dialog.setView(layout); et_search = (EditText) layout.findViewById(R.id.searchC); et_search.setHint(hintText); dialog.setPositiveButton( OKText, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { String s = et_search.getText().toString().trim(); callBack.exectEditEvent(s); } }); dialog.setNegativeButton( R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) {} }); dialog.show(); }
public static void installBusyBox(SherlockActivity context) { DialogHelper.context = context; AlertDialog.Builder builder = new AlertDialog.Builder(context); builder .setMessage(R.string.installbusybox) .setCancelable(false) .setPositiveButton( R.string.button_ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Intent goToMarket = null; goToMarket = new Intent( Intent.ACTION_VIEW, Uri.parse("market://details?id=stericson.busybox")); DialogHelper.context.startActivity(goToMarket); dialog.cancel(); } }) .setNegativeButton( R.string.button_abprt, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alert = builder.create(); alert.show(); }
private Dialog createUndockedMessage() { final AlertDialog.Builder ab = new AlertDialog.Builder(getActivity()); ab.setTitle(R.string.dock_not_found_title); ab.setMessage(R.string.dock_not_found_text); ab.setPositiveButton(android.R.string.ok, null); return ab.create(); }
@Override public void onPrepareDialogBuilder(final AlertDialog.Builder builder) { super.onPrepareDialogBuilder(builder); prefs = getSharedPreferences(); if (prefs == null) return; final int length = mKeys.length; for (int i = 0; i < length; i++) { mValues[i] = prefs.getBoolean(mKeys[i], mDefaultValues[i]); } builder.setPositiveButton(android.R.string.ok, this); builder.setNegativeButton(android.R.string.cancel, null); builder.setMultiChoiceItems(mNames, mValues, this); if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.DONUT) { new Thread() { @Override public void run() { Dialog dialog = null; while (dialog == null) { dialog = getDialog(); if (dialog != null) { final Message msg = new Message(); msg.obj = dialog; mDialogWorkaroundHandler.sendMessage(msg); } try { sleep(50L); } catch (final InterruptedException e) { } } } }.start(); } }
/** * 显示对话框 * * @param title 对话框标题 * @param message 对话框内容 */ protected void showAlertDialog(String title, String message) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(title); builder.setMessage(message); builder.setPositiveButton(getString(android.R.string.ok), null); builder.show(); }
private AlertDialog createDialog(SubtypePreference subtypePref) { final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder .setTitle(R.string.custom_input_styles_title) .setMessage(R.string.custom_input_style_note_message) .setNegativeButton(R.string.not_now, null) .setPositiveButton( R.string.enable, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { final Intent intent = CompatUtils.getInputLanguageSelectionIntent( ImfUtils.getInputMethodIdOfThisIme(getActivity()), Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED | Intent.FLAG_ACTIVITY_CLEAR_TOP); // TODO: Add newly adding subtype to extra value of the intent as a hint // for the input language selection activity. // intent.putExtra("newlyAddedSubtype", subtypePref.getSubtype()); startActivity(intent); } }); return builder.create(); }
private void showErrorMessage(int message) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(message); builder.setPositiveButton(R.string.button_ok, new FinishListener(this)); builder.setOnCancelListener(new FinishListener(this)); builder.show(); }
/** 显示帐号在别处登录dialog */ private void showConflictDialog() { isConflictDialogShow = true; DemoHXSDKHelper.getInstance().logout(false, null); String st = getResources().getString(R.string.Logoff_notification); if (mycontext.isFinishing()) { // clear up global variables try { if (conflictBuilder == null) conflictBuilder = new android.app.AlertDialog.Builder(mycontext); conflictBuilder.setTitle(st); conflictBuilder.setMessage(R.string.connect_conflict); conflictBuilder.setPositiveButton( R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); conflictBuilder = null; finish(); startActivity(new Intent(mycontext, LoginContainerActivity.class)); } }); conflictBuilder.setCancelable(false); conflictBuilder.create().show(); isConflict = true; } catch (Exception e) { EMLog.e(TAG, "---------color conflictBuilder error" + e.getMessage()); } } }
@OnClick(R.id.editGroupPhoto) public void editPhoto() { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setItems(R.array.camera_choices, mDialogInterface); AlertDialog dialog = builder.create(); dialog.show(); }
private void showLocationServiceDisabledAlertToUser() { AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); alertDialogBuilder // GPS is disabled in your device. Would you like to enable it? .setMessage(R.string.location_services_on_device_deactivated) .setCancelable(false) // Goto Settings Page To Enable GPS .setPositiveButton( R.string.activate_location_services_on_device, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Intent callGPSSettingIntent = new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS); startActivity(callGPSSettingIntent); } }); alertDialogBuilder.setNegativeButton( "Fortryd", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alert = alertDialogBuilder.create(); alert.show(); }
private void showPopUpCashless() { final CharSequence[] items = {"Only Cashless", "All garages"}; AlertDialog.Builder helpBuilder = new AlertDialog.Builder(this); helpBuilder.setTitle("Make Selection"); helpBuilder.setSingleChoiceItems( items, 0, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { Toast.makeText(getApplicationContext(), items[item], Toast.LENGTH_SHORT).show(); radioTimeSelected = item; ShowMapActivity.cashSelected = item; } }); helpBuilder.setPositiveButton( "Confirm", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Toast.makeText(SearchSettingsActivity.this, "Success", Toast.LENGTH_SHORT).show(); } }); // Remember, create doesn't show the dialog AlertDialog helpDialog = helpBuilder.create(); helpDialog.show(); }
// Lifecycle method to handle menu option actions @Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); // Allows the user to choose whether to take a new photo, or choose a photo from the Gallery if (id == R.id.action_camera) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setItems( R.array.camera_choices, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int position) { if (position == REQUEST_IMAGE_CAPTURE) { takePicture(); } else if (position == REQUEST_IMAGE_CHOOSE) { Intent choosePhotoIntent = new Intent(Intent.ACTION_GET_CONTENT); choosePhotoIntent.addCategory(Intent.CATEGORY_OPENABLE); choosePhotoIntent.setType("image/*"); startActivityForResult(choosePhotoIntent, REQUEST_IMAGE_CHOOSE); } } }); AlertDialog dialog = builder.create(); dialog.show(); } // Refreshes the feed by re-loading the freed fragment (which in turn calls the API for new // data) if (id == R.id.action_refresh) { FragmentTransaction transaction = getFragmentManager().beginTransaction(); transaction.replace(R.id.content_frame, new FeedFragment()).commit(); } return super.onOptionsItemSelected(item); }
public void apply(View v) { // read raw values from the input widgets master_switch = switch_master_switch.isChecked(); left_margin = Integer.parseInt(ET_left_margin.getText().toString()); right_margin = Integer.parseInt(ET_right_margin.getText().toString()); top_margin = Integer.parseInt(ET_top_margin.getText().toString()); bottom_margin = Integer.parseInt(ET_bottom_margin.getText().toString()); leave_actionbar = CB_leave_actionbar.isChecked(); // move_statusbar = CB_move_statusbar.isChecked(); // check for bad margins int viewH = (screen_height - top_margin - bottom_margin); int viewW = screen_width - left_margin - right_margin; String message = null; if (viewW < screen_width * 0.5 || viewH < screen_height * 0.5) message = "The view area is less than half your screen. It may be too small. Are you " + "sure you want to save?"; else if (left_margin > screen_width || top_margin > screen_height || right_margin < 0 || bottom_margin < 0) message = "The view area does not fit on the screen. Are you sure you want to apply?"; else save(); if (message != null) { AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle("Warning"); alert.setMessage(message); } finish(); }
public void doActionOnAlert(View view) { // Ouvre une fenêtre de dialogue pour choisir une action à effectué sur l'alerte Resources res = getResources(); final CharSequence[] items = res.getStringArray(R.array.list_action_alert); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(getString(R.string.title_list_alert_action)); builder.setItems( items, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { switch (item) { case OMW: manager.updateAlertOMW(currentAlert.getId()); break; case POLICE: call911(); break; case SAMU: callSamu(); break; case WRONG_ALERT: manager.updateAlertBullshit(currentAlert.getId()); break; } } }); AlertDialog alert = builder.create(); alert.show(); }
public void park(final Activity ctx) { AlertDialog.Builder alertBuilder = new AlertDialog.Builder(ctx); final String regno = pref("regno", "", ctx); final String msg = "Alustan parkimist s›idukile " + regno + " tsoonis " + key; alertBuilder .setMessage(msg + "?") .setCancelable(false) .setPositiveButton( "Jah", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { String msg = regno + " " + key; SmsManager sm = SmsManager.getDefault(); sm.sendTextMessage("1902", null, msg, null, null); send_notification("Parkimine alustatud ", "s›iduk " + regno + " tsoon " + key, ctx); set_pref("parking_active", "true", ctx); set_pref("start_time", new Long(SystemClock.elapsedRealtime()).toString(), ctx); ctx.finish(); } }) .setNegativeButton( "Ei", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); alertBuilder.create(); alertBuilder.show(); }
@Override protected void onProgressUpdate(String... values) { super.onProgressUpdate(values); // EditText passwordField = (EditText) // parent.findViewById(R.id.LoginScreen_EditTextPassword); String[] message_parts = values[0].split(":"); // FORMAT: [TYPE]:[EMAIL]:[TOKEN]:[DATA]:[EOP] // 0 1 2 3 4 Log.v("REC_M", "RECEIVED:" + values[0]); if (message_parts.length == 5) { String TYPE = message_parts[0]; String Status = message_parts[3]; Log.v("TYPE", "TYPE:" + TYPE); if (TYPE.equals("STATUS")) { AlertDialog.Builder alertDialog = new AlertDialog.Builder(parent); alertDialog.setTitle(" User Alert !"); alertDialog.setMessage(Status); alertDialog.setPositiveButton( "OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) {} }); alertDialog.show(); (parent.findViewById(R.id.ForgotPassword_ButtonResetPassword)).setEnabled(true); } } }
private void showProfileDialog() { AlertDialog.Builder alert = new AlertDialog.Builder(BaseActivity.this); alert.setItems( new String[] { getResources().getString(R.string.view_profile), getResources().getString(R.string.log_out) }, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { switch (item) { case 0: showUserProfile(); break; case 1: logOut(); break; } } }); alert.setNegativeButton( R.string.no, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog ad = alert.create(); ad.show(); }
public void showErrorDialog() { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.error).setMessage(R.string.error_loading_orders); AlertDialog alert = builder.create(); alert.show(); }
public void showEmptyDialog() { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.info).setMessage(R.string.no_new_orders); AlertDialog alert = builder.create(); alert.show(); }
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); View view = getActivity().getLayoutInflater().inflate(R.layout.marker_upload, null); final EditText txtName = (EditText) view.findViewById(R.id.txtName); builder .setView(view) .setTitle("Upload Markers") .setPositiveButton( "Upload", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { mListener.onUploadDialogPositiveClick(txtName.getText().toString()); } }) .setNegativeButton( "Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dismiss(); } }); return builder.create(); }
private void showConfirmDialog(final int monthType) { // TODO Auto-generated method stub AlertDialog.Builder builder = new AlertDialog.Builder(this); int[] month = {1, 3, 6, 12}; int[] money = {11000, 31000, 61000, 110000}; builder.setMessage("开通" + month[monthType] + "个月会员,需花费" + money[monthType] + "金币"); builder.setPositiveButton( "开通", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub buyVIP(monthType); } }); builder.setNegativeButton( "取消", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub } }); AlertDialog confDialog = builder.create(); confDialog.show(); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main12); ConnectivityManager cManager = (ConnectivityManager) getSystemService(this.CONNECTIVITY_SERVICE); NetworkInfo ninfo = cManager.getActiveNetworkInfo(); if (ninfo != null && ninfo.isConnected()) { } else { AlertDialog.Builder builder1 = new AlertDialog.Builder(this); builder1.setMessage("Sorry There is no internet please check your connection!"); builder1.setCancelable(true); builder1.setPositiveButton( "I Will!", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alert11 = builder1.create(); alert11.show(); } itemlist = new ArrayList<RSSItem>(); new RetrieveRSSFeeds().execute(); }
@Override public boolean onItemLongClick(final AdapterView<?> adapterView, View view, final int i, long l) { if (i == 0) { return false; } final ContactsSource.LocalContact contact = (ContactsSource.LocalContact) adapterView.getItemAtPosition(i); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(contact.displayName); if (contact.user != null) { builder.setItems( new CharSequence[] { getStringSafe(R.string.st_contacts_action_view), getStringSafe(R.string.st_contacts_action_share), getStringSafe(R.string.st_contacts_action_delete), getStringSafe(R.string.st_contacts_action_block), getStringSafe(R.string.st_contacts_action_block_and_delete) }, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { if (i == 0) { viewInBookContact(contact); } else if (i == 1) { shareContact(contact); } else if (i == 2) { deleteContact(contact); } else if (i == 3) { blockContact(contact); } else if (i == 4) { blockDeleteContact(contact); } } }); } else { builder.setItems( new CharSequence[] { getStringSafe(R.string.st_contacts_action_view), getStringSafe(R.string.st_contacts_action_delete), }, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { if (i == 0) { viewInBookContact(contact); } else if (i == 1) { deleteContact(contact); } } }); } AlertDialog contextMenu = builder.create(); contextMenu.setCanceledOnTouchOutside(true); contextMenu.show(); return true; }
/* * Functions for taking a picture */ private void changePictureDialog() { AlertDialog.Builder builder = new AlertDialog.Builder(MY_CONTEXT); builder .setMessage("A picture was already taken! Do you want to replace it?") .setCancelable(false) .setPositiveButton( "Retake Picture", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { /* * User is directed to comments section */ takePicture(); } }) .setNegativeButton( "Keep current picture", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // do nothing, dismiss dialog } }); AlertDialog dialog = builder.create(); dialog.show(); }
private void promptUserForGPS() { /* * create dialogue for user to turn on GPS or skip to userform */ AlertDialog.Builder builder = new AlertDialog.Builder(MY_CONTEXT); builder .setMessage("GPS is disabled. Enable GPS?") .setCancelable(false) .setPositiveButton( "Change GPS Settings", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { /* * User is directed to phone settings to turn on GPS * the answer is caught in onActivityResult with SETTINGS_ACTIVITY_KEY */ Intent myIntent = new Intent(Settings.ACTION_SECURITY_SETTINGS); startActivityForResult(myIntent, SETTINGS_ACTIVITY_KEY); } }) .setNegativeButton( "Ignore", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // just dismiss dialog } }); AlertDialog dialog = builder.create(); dialog.show(); }
private void showPopUpManuf(CharSequence[] data) { // CharSequence[] items = {"All models","Audi","Ford","Hyundai","Mahindra & // Mahindra","Maruti","Tata"}; final CharSequence[] items = data; AlertDialog.Builder helpBuilder = new AlertDialog.Builder(this); helpBuilder.setTitle("Make Selection"); helpBuilder.setSingleChoiceItems( items, 0, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { Toast.makeText(getApplicationContext(), items[item], Toast.LENGTH_SHORT).show(); radioTimeSelected = item; String slc = (String) items[item]; if (item == 0) ShowMapActivity.manufSelected = null; else ShowMapActivity.manufSelected = slc; } }); helpBuilder.setPositiveButton( "Confirm", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Toast.makeText(SearchSettingsActivity.this, "Success", Toast.LENGTH_SHORT).show(); } }); // Remember, create doesn't show the dialog AlertDialog helpDialog = helpBuilder.create(); helpDialog.show(); }
private void showPopUpDistance() { final CharSequence[] items = {"5 km", "10 km", "25 km", "50 km", "No limit"}; final int[] arrDist = {5, 10, 25, 50}; AlertDialog.Builder helpBuilder = new AlertDialog.Builder(this); helpBuilder.setTitle("Make Selection"); helpBuilder.setSingleChoiceItems( items, 0, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { Toast.makeText(getApplicationContext(), items[item], Toast.LENGTH_SHORT).show(); radioTimeSelected = item; if (item == 4) ShowMapActivity.distSelected = -1; else ShowMapActivity.distSelected = arrDist[item]; } }); helpBuilder.setPositiveButton( "Confirm", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Toast.makeText(SearchSettingsActivity.this, "Success", Toast.LENGTH_SHORT).show(); } }); // Remember, create doesn't show the dialog AlertDialog helpDialog = helpBuilder.create(); helpDialog.show(); }