List of usage examples for android.app AlertDialog setCancelable
public void setCancelable(boolean flag)
From source file:com.xperia64.rompatcher.MainActivity.java
private void patchCheck() { // Just try to interpret the following if statement. I dare you. if (new File(Globals.fileToPatch + ".bak").exists() || (Globals.fileToPatch.toLowerCase(Locale.US).endsWith(".ecm") && new File( Globals.fileToPatch.substring(0, Globals.fileToPatch.lastIndexOf('.'))).exists()) || new File(Globals.fileToPatch + ".new").exists() || (new File(Globals.fileToPatch.substring(0, Globals.fileToPatch.lastIndexOf('/') + 1) + ed.getText().toString() + ((e.isChecked())/*from w ww . j av a 2s . co m*/ ? ((Globals.fileToPatch.lastIndexOf('.') > -1) ? Globals.fileToPatch.substring( Globals.fileToPatch.lastIndexOf('.'), Globals.fileToPatch.length()) : "") : "")).exists() && d.isChecked() && c.isChecked())) { System.out.println("bad"); AlertDialog dialog2 = new AlertDialog.Builder(staticThis).create(); dialog2.setTitle(getResources().getString(R.string.warning)); dialog2.setMessage(getResources().getString(R.string.warning_desc)); dialog2.setCancelable(false); dialog2.setButton(DialogInterface.BUTTON_POSITIVE, getResources().getString(android.R.string.yes), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int buttonId) { new File(Globals.fileToPatch + ".bak").delete(); new File(Globals.fileToPatch + ".new").delete(); if (Globals.fileToPatch.toLowerCase(Locale.US).endsWith(".ecm")) new File(Globals.fileToPatch.substring(0, Globals.fileToPatch.lastIndexOf('.'))) .delete(); new File(Globals.fileToPatch.substring(0, Globals.fileToPatch.lastIndexOf('/') + 1) + ed.getText().toString() + ((e.isChecked()) ? ((Globals.fileToPatch.lastIndexOf('.') > -1) ? Globals.fileToPatch.substring(Globals.fileToPatch.lastIndexOf('.'), Globals.fileToPatch.length()) : "") : "")).delete(); if (d.isChecked() && c.isChecked() && e.isChecked() && Globals.fileToPatch.lastIndexOf('.') > -1) { ed.setText(ed.getText() + Globals.fileToPatch.substring( Globals.fileToPatch.lastIndexOf('.'), Globals.fileToPatch.length())); } patch(c.isChecked(), d.isChecked(), r.isChecked(), ed.getText().toString()); } }); dialog2.setButton(DialogInterface.BUTTON_NEGATIVE, getResources().getString(android.R.string.cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int buttonId) { Toast t = Toast.makeText(staticThis, getResources().getString(R.string.nopatch), Toast.LENGTH_SHORT); t.show(); } }); dialog2.show(); } else { if (d.isChecked() && c.isChecked() && e.isChecked() && Globals.fileToPatch.lastIndexOf('.') > -1) { ed.setText(ed.getText() + Globals.fileToPatch.substring(Globals.fileToPatch.lastIndexOf('.'), Globals.fileToPatch.length())); } patch(c.isChecked(), d.isChecked(), r.isChecked(), ed.getText().toString()); } }
From source file:io.jari.geenstijl.Dialogs.LoginDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); // Get the layout inflater LayoutInflater inflater = getActivity().getLayoutInflater(); // Inflate and set the layout for the dialog // Pass null as the parent view because its going in the dialog layout final View view = inflater.inflate(R.layout.dialog_login, null); builder.setView(view)/*from www .ja v a 2 s. co m*/ // Add action buttons .setPositiveButton(R.string.signin, null) .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { LoginDialog.this.getDialog().cancel(); } }).setTitle(R.string.signin); final AlertDialog alertDialog = builder.create(); alertDialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { //i wrote this code with a certain amount of alcohol in my blood, so i can't vouch for it's readability final View error = view.findViewById(R.id.error); final Button positive = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE); final Button negative = alertDialog.getButton(AlertDialog.BUTTON_NEGATIVE); positive.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { positive.setEnabled(false); negative.setEnabled(false); final TextView username = (TextView) view.findViewById(R.id.username); final TextView password = (TextView) view.findViewById(R.id.password); final View loading = view.findViewById(R.id.loading); username.setVisibility(View.GONE); password.setVisibility(View.GONE); loading.setVisibility(View.VISIBLE); error.setVisibility(View.GONE); alertDialog.setCancelable(false); new Thread(new Runnable() { public void run() { boolean success; try { success = API.logIn(username.getText().toString(), password.getText().toString(), LoginDialog.this.getActivity()); } catch (Exception e) { e.printStackTrace(); success = false; } alertDialog.setCancelable(true); if (!success) activity.runOnUiThread(new Runnable() { public void run() { username.setVisibility(View.VISIBLE); password.setVisibility(View.VISIBLE); error.setVisibility(View.VISIBLE); positive.setEnabled(true); negative.setEnabled(true); loading.setVisibility(View.GONE); } }); else activity.runOnUiThread(new Runnable() { public void run() { alertDialog.dismiss(); forceOptionsReload(); Crouton.makeText(activity, getString(R.string.loggedin, API.getUsername(activity)), Style.CONFIRM).show(); } }); } }).start(); } }); } }); return alertDialog; }
From source file:info.zamojski.soft.towercollector.MainActivity.java
private void askAndSetGpsEnabled() { if (GpsUtils.isGpsEnabled(getApplication())) { Log.d("askAndSetGpsEnabled(): GPS enabled"); isGpsEnabled = true;/* www. j a va 2 s . c o m*/ showAskForLocationSettingsDialog = false; } else { Log.d("askAndSetGpsEnabled(): GPS disabled, asking user"); isGpsEnabled = false; AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(R.string.dialog_want_enable_gps) .setPositiveButton(R.string.dialog_yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Log.d("askAndSetGpsEnabled(): display settings"); Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); try { startActivity(intent); showAskForLocationSettingsDialog = true; } catch (ActivityNotFoundException ex1) { intent = new Intent(Settings.ACTION_SECURITY_SETTINGS); try { startActivity(intent); showAskForLocationSettingsDialog = true; } catch (ActivityNotFoundException ex2) { Log.w("askAndSetGpsEnabled(): Could not open Settings to enable GPS"); MyApplication.getAnalytics().sendException(ex2, Boolean.FALSE); ACRA.getErrorReporter().handleSilentException(ex2); AlertDialog alertDialog = new AlertDialog.Builder(MainActivity.this) .setMessage(R.string.dialog_could_not_open_gps_settings) .setPositiveButton(R.string.dialog_ok, null).create(); alertDialog.setCanceledOnTouchOutside(true); alertDialog.setCancelable(true); alertDialog.show(); } } finally { dialog.dismiss(); } } }).setNegativeButton(R.string.dialog_no, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Log.d("askAndSetGpsEnabled(): cancel"); dialog.cancel(); if (GpsUtils.isGpsEnabled(getApplication())) { Log.d("askAndSetGpsEnabled(): provider enabled in the meantime"); startCollectorServiceWithCheck(); } else { isGpsEnabled = false; showAskForLocationSettingsDialog = false; } } }); AlertDialog dialog = builder.create(); dialog.setCanceledOnTouchOutside(true); dialog.setCancelable(true); dialog.show(); } }
From source file:com.xperia64.timidityae.PlayerFragment.java
@SuppressLint("InflateParams") public void showMidiDialog() { AlertDialog.Builder b = new AlertDialog.Builder(getActivity()); View v = getActivity().getLayoutInflater().inflate(R.layout.midi_options, null); Button speedUp = (Button) v.findViewById(R.id.speedUp); Button slowDown = (Button) v.findViewById(R.id.slowDown); Button keyUp = (Button) v.findViewById(R.id.keyUp); Button keyDown = (Button) v.findViewById(R.id.keyDown); Button vplus = (Button) v.findViewById(R.id.vplus); Button vminus = (Button) v.findViewById(R.id.vminus); Button export = (Button) v.findViewById(R.id.exportButton); Button saveCfg = (Button) v.findViewById(R.id.saveCfg); Button loadCfg = (Button) v.findViewById(R.id.loadCfg); Button savedefCfg = (Button) v.findViewById(R.id.savedefCfg); final Button deldefCfg = (Button) v.findViewById(R.id.deldefCfg); deldefCfg.setEnabled(new File(mActivity.currSongName + ".def.tcf").exists() || new File(mActivity.currSongName + ".def.tzf").exists()); tempo = (TextView) v.findViewById(R.id.tempoText); pitch = (TextView) v.findViewById(R.id.pitchText); voices = (TextView) v.findViewById(R.id.voiceText); tempo.setText(String.format(getResources().getString(R.string.mop_tempo), JNIHandler.ttr, (int) (500000 / (double) JNIHandler.tt * 120 * (double) JNIHandler.ttr / 100 + 0.5))); pitch.setText(String.format(getResources().getString(R.string.mop_pitch), ((JNIHandler.koffset > 0) ? "+" : "") + Integer.toString(JNIHandler.koffset))); voices.setText(/*from w ww. j ava2s . com*/ String.format(getResources().getString(R.string.mop_voice), JNIHandler.voice, JNIHandler.maxvoice)); speedUp.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { JNIHandler.controlTimidity(17, 1); JNIHandler.waitUntilReady(); JNIHandler.tb++; } }); slowDown.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { JNIHandler.controlTimidity(18, 1); JNIHandler.waitUntilReady(); JNIHandler.tb--; } }); keyUp.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { JNIHandler.controlTimidity(15, 1); JNIHandler.waitUntilReady(); } }); keyDown.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { JNIHandler.controlTimidity(16, -1); JNIHandler.waitUntilReady(); } }); vplus.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { JNIHandler.controlTimidity(19, 5); JNIHandler.waitUntilReady(); } }); vminus.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { JNIHandler.controlTimidity(20, 5); JNIHandler.waitUntilReady(); } }); export.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { mActivity.dynExport(); } }); saveCfg.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { mActivity.saveCfg(); } }); loadCfg.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { mActivity.loadCfg(); } }); savedefCfg.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { String value1; String value2; boolean alreadyExists = (new File(mActivity.currSongName + ".def.tcf").exists() || new File(mActivity.currSongName + ".def.tzf").exists()); boolean aWrite = true; String needRename1 = null; String needRename2 = null; String probablyTheRoot = ""; String probablyTheDirectory = ""; try { if (Globals.compressCfg) new FileOutputStream(mActivity.currSongName + ".def.tzf", true).close(); else new FileOutputStream(mActivity.currSongName + ".def.tcf", true).close(); } catch (FileNotFoundException e) { aWrite = false; } catch (IOException e) { e.printStackTrace(); } final boolean canWrite = aWrite; if (!alreadyExists && canWrite) { new File(mActivity.currSongName + ".def.tcf").delete(); new File(mActivity.currSongName + ".def.tzf").delete(); } if (canWrite && new File(mActivity.currSongName).canWrite()) { value1 = mActivity.currSongName + (Globals.compressCfg ? ".def.tzf" : ".def.tcf"); value2 = mActivity.currSongName + (Globals.compressCfg ? ".def.tcf" : ".def.tzf"); } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && Globals.theFold != null) { //TODO // Write the file to getExternalFilesDir, then move it with the Uri // We need to tell JNIHandler that movement is needed. // This is pretty much done now? String[] tmp = Globals.getDocFilePaths(getActivity(), mActivity.currSongName); probablyTheDirectory = tmp[0]; probablyTheRoot = tmp[1]; if (probablyTheDirectory.length() > 1) { needRename1 = (mActivity.currSongName).substring( mActivity.currSongName.indexOf(probablyTheRoot) + probablyTheRoot.length()) + (Globals.compressCfg ? ".def.tzf" : ".def.tcf"); needRename2 = (mActivity.currSongName).substring( mActivity.currSongName.indexOf(probablyTheRoot) + probablyTheRoot.length()) + (Globals.compressCfg ? ".def.tcf" : ".def.tzf"); value1 = probablyTheDirectory + mActivity.currSongName.substring(mActivity.currSongName.lastIndexOf('/')) + (Globals.compressCfg ? ".def.tzf" : ".def.tcf"); value2 = probablyTheDirectory + mActivity.currSongName.substring(mActivity.currSongName.lastIndexOf('/')) + (Globals.compressCfg ? ".def.tcf" : ".def.tzf"); } else { Toast.makeText(getActivity(), "Could not write config file. Did you give Timidity write access to the root of your external sd card?", Toast.LENGTH_SHORT).show(); return; } } else { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Toast.makeText(getActivity(), "Could not write config file. Did you give Timidity write access to the root of your external sd card?", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(getActivity(), "Could not write config file. Permission denied.", Toast.LENGTH_SHORT).show(); } return; } final String finalval1 = value1; final String finalval2 = value2; final String needToRename1 = needRename1; final String needToRename2 = needRename2; final String probRoot = probablyTheRoot; if (alreadyExists) { AlertDialog dialog = new AlertDialog.Builder(mActivity).create(); dialog.setTitle("Warning"); dialog.setMessage("Overwrite default config file?"); dialog.setCancelable(false); dialog.setButton(DialogInterface.BUTTON_POSITIVE, getResources().getString(android.R.string.yes), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int buttonId) { if (!canWrite && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (needToRename1 != null) { Globals.tryToDeleteFile(getActivity(), probRoot + needToRename1); Globals.tryToDeleteFile(getActivity(), finalval1); Globals.tryToDeleteFile(getActivity(), probRoot + needToRename2); Globals.tryToDeleteFile(getActivity(), finalval2); } else { Globals.tryToDeleteFile(getActivity(), finalval1); Globals.tryToDeleteFile(getActivity(), finalval2); } } else { new File(mActivity.currSongName + ".def.tcf").delete(); new File(mActivity.currSongName + ".def.tzf").delete(); } mActivity.localfinished = false; mActivity.saveCfgPart2(finalval1, needToRename1); deldefCfg.setEnabled(true); /*Intent new_intent = new Intent(); new_intent.setAction(getResources().getString(R.string.msrv_rec)); new_intent.putExtra(getResources().getString(R.string.msrv_cmd), 16); new_intent.putExtra(getResources().getString(R.string.msrv_outfile), mActivity.currSongName+".def.tcf"); getActivity().sendBroadcast(new_intent); deldefCfg.setEnabled(true);*/ } }); dialog.setButton(DialogInterface.BUTTON_NEGATIVE, getResources().getString(android.R.string.no), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int buttonId) { } }); dialog.show(); } else { /*Intent new_intent = new Intent(); new_intent.setAction(getResources().getString(R.string.msrv_rec)); new_intent.putExtra(getResources().getString(R.string.msrv_cmd), 16); new_intent.putExtra(getResources().getString(R.string.msrv_outfile), mActivity.currSongName+".def.tcf"); getActivity().sendBroadcast(new_intent); deldefCfg.setEnabled(true);*/ mActivity.localfinished = false; mActivity.saveCfgPart2(finalval1, needToRename1); deldefCfg.setEnabled(true); } } }); deldefCfg.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { if (new File(mActivity.currSongName + ".def.tcf").exists() || new File(mActivity.currSongName + ".def.tzf").exists()) { boolean aWrite = true; try { if (Globals.compressCfg) new FileOutputStream(mActivity.currSongName + ".def.tzf", true).close(); else new FileOutputStream(mActivity.currSongName + ".def.tcf", true).close(); } catch (FileNotFoundException e) { aWrite = false; } catch (IOException e) { e.printStackTrace(); } final boolean canWrite = aWrite; AlertDialog dialog = new AlertDialog.Builder(mActivity).create(); dialog.setTitle("Warning"); dialog.setMessage("Really delete default config file?"); dialog.setCancelable(false); dialog.setButton(DialogInterface.BUTTON_POSITIVE, getResources().getString(android.R.string.yes), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int buttonId) { if (!canWrite && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Globals.tryToDeleteFile(getActivity(), mActivity.currSongName + ".def.tzf"); Globals.tryToDeleteFile(getActivity(), mActivity.currSongName + ".def.tcf"); } else { new File(mActivity.currSongName + ".def.tcf").delete(); new File(mActivity.currSongName + ".def.tzf").delete(); } deldefCfg.setEnabled(false); } }); dialog.setButton(DialogInterface.BUTTON_NEGATIVE, getResources().getString(android.R.string.no), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int buttonId) { } }); dialog.show(); } } }); final Spinner x = (Spinner) v.findViewById(R.id.resampSpinner); List<String> arrayAdapter = new ArrayList<String>(); for (String yyy : Globals.sampls) arrayAdapter.add(yyy); ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_item, arrayAdapter); dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); x.setAdapter(dataAdapter); firstSelection = true; x.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> arg0, View arg1, int pos, long id) { if (firstSelection) firstSelection = false; else { JNIHandler.setResampleTimidity(JNIHandler.currsamp = pos); JNIHandler.seekTo(JNIHandler.currTime); } } @Override public void onNothingSelected(AdapterView<?> arg0) { } }); x.setSelection(JNIHandler.currsamp); if (Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH) v.setBackgroundColor(Globals.theme == 1 ? Color.WHITE : Color.BLACK); b.setView(v); b.setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); b.setTitle(getActivity().getResources().getString(R.string.mop)); ddd = b.create(); ddd.show(); }
From source file:com.appdupe.flamer.LoginUsingFacebook.java
private void ErrorMessageLocationNotFonr(String title, String message) { AlertDialog.Builder builder = new AlertDialog.Builder(LoginUsingFacebook.this); builder.setTitle(title);/*from w w w. j a v a2 s . c o m*/ builder.setMessage(message); builder.setPositiveButton(getResources().getString(R.string.okbuttontext), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); AlertDialog alert = builder.create(); alert.setCancelable(false); alert.show(); }
From source file:com.appdupe.flamer.LoginUsingFacebook.java
/** * Showing an alert dialog to usre in case of any error. * //from w w w . j a va 2 s . com * @param title * - title for the dialog. * @param message * - error message. */ private void ErrorMessage(String title, String message) { AlertDialog.Builder builder = new AlertDialog.Builder(LoginUsingFacebook.this); builder.setTitle(title); builder.setMessage(message); builder.setPositiveButton(getResources().getString(R.string.okbuttontext), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); AlertDialog alert = builder.create(); alert.setCancelable(false); alert.show(); }
From source file:com.ushahidi.android.app.ui.phone.AddReportActivity.java
/** * Create various dialog/*from ww w .j av a2 s . com*/ */ @Override protected Dialog onCreateDialog(int id) { switch (id) { case DIALOG_ERROR_NETWORK: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.network_error)); dialog.setMessage(getString(R.string.network_error_msg)); dialog.setButton2(getString(R.string.ok), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } case DIALOG_ERROR_SAVING: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.network_error)); dialog.setMessage(getString(R.string.file_system_error_msg)); dialog.setButton2(getString(R.string.ok), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } case DIALOG_CHOOSE_IMAGE_METHOD: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.choose_method)); dialog.setMessage(getString(R.string.how_to_select_pic)); dialog.setButton(getString(R.string.gallery_option), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_PICK); intent.setData(MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(intent, REQUEST_CODE_IMAGE); dialog.dismiss(); } }); dialog.setButton2(getString(R.string.cancel), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setButton3(getString(R.string.camera_option), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, PhotoUtils.getPhotoUri(photoName, AddReportActivity.this)); startActivityForResult(intent, REQUEST_CODE_CAMERA); dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } case DIALOG_MULTIPLE_CATEGORY: { if (showCategories() != null) { return new AlertDialog.Builder(this).setTitle(R.string.choose_categories) .setMultiChoiceItems(showCategories(), setCheckedCategories(), new DialogInterface.OnMultiChoiceClickListener() { public void onClick(DialogInterface dialog, int whichButton, boolean isChecked) { // see if categories have previously if (isChecked) { mVectorCategories.add(mCategoriesId.get(whichButton)); mError = false; } else { mVectorCategories.remove(mCategoriesId.get(whichButton)); } setSelectedCategories(mVectorCategories); } }) .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { /* User clicked Yes so do some stuff */ } }).create(); } } case TIME_DIALOG_ID: return new TimePickerDialog(this, mTimeSetListener, mCalendar.get(Calendar.HOUR), mCalendar.get(Calendar.MINUTE), false); case DATE_DIALOG_ID: return new DatePickerDialog(this, mDateSetListener, mCalendar.get(Calendar.YEAR), mCalendar.get(Calendar.MONTH), mCalendar.get(Calendar.DAY_OF_MONTH)); case DIALOG_SHOW_MESSAGE: AlertDialog.Builder messageBuilder = new AlertDialog.Builder(this); messageBuilder.setMessage(mErrorMessage).setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog showDialog = messageBuilder.create(); showDialog.show(); break; case DIALOG_SHOW_REQUIRED: AlertDialog.Builder requiredBuilder = new AlertDialog.Builder(this); requiredBuilder.setTitle(R.string.required_fields); requiredBuilder.setMessage(mErrorMessage).setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog showRequiredDialog = requiredBuilder.create(); showRequiredDialog.show(); break; // prompt for unsaved changes case DIALOG_SHOW_PROMPT: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.unsaved_changes)); dialog.setMessage(getString(R.string.want_to_cancel)); dialog.setButton(getString(R.string.no), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setButton2(getString(R.string.yes), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { finish(); dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } // prompt for report deletion case DIALOG_SHOW_DELETE_PROMPT: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.delete_report)); dialog.setMessage(getString(R.string.want_to_delete)); dialog.setButton(getString(R.string.no), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setButton2(getString(R.string.yes), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // delete report deleteReport(); dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } } return null; }
From source file:com.oasis.sdk.activity.GooglePlayBillingActivity.java
/** * ??????/*ww w.j a v a 2 s . co m*/ * @param purchase */ void alert(final Purchase purchase) { final AlertDialog d = new AlertDialog.Builder(this).create(); d.show(); d.setContentView(BaseUtils.getResourceValue("layout", "oasisgames_sdk_common_dialog_notitle")); d.setCanceledOnTouchOutside(false); d.setCancelable(false); TextView retry = (TextView) d .findViewById(BaseUtils.getResourceValue("id", "oasisgames_sdk_common_dialog_notitle_sure")); retry.setText(getResources() .getString(BaseUtils.getResourceValue("string", "oasisgames_sdk_pay_google_notice_alert_retry"))); retry.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // ? d.dismiss(); setWaitScreen(true); check(purchase); } }); TextView close = (TextView) d .findViewById(BaseUtils.getResourceValue("id", "oasisgames_sdk_common_dialog_notitle_cancle")); close.setText(getResources() .getString(BaseUtils.getResourceValue("string", "oasisgames_sdk_pay_google_notice_alert_close"))); close.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { d.dismiss(); setResultInfo(OASISPlatformConstant.RESULT_EXCEPTION_GOOGLEPAY_EXCEPTION, "?????"); close(); } }); TextView content = (TextView) d .findViewById(BaseUtils.getResourceValue("id", "oasisgames_sdk_common_dialog_notitle_content")); content.setText(getResources() .getString(BaseUtils.getResourceValue("string", "oasisgames_sdk_pay_google_notice_alert_content"))); }
From source file:org.odk.collect.android.activities.GoogleDriveActivity.java
private void createAlertDialog(String message) { Collect.getInstance().getActivityLogger().logAction(this, "createAlertDialog", "show"); AlertDialog alertDialog = new AlertDialog.Builder(this).create(); alertDialog.setTitle(getString(R.string.download_forms_result)); alertDialog.setMessage(message);/* w w w .jav a 2 s . c om*/ DialogInterface.OnClickListener quitListener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int i) { switch (i) { case DialogInterface.BUTTON1: // ok Collect.getInstance().getActivityLogger().logAction(this, "createAlertDialog", "OK"); alertShowing = false; finish(); break; } } }; alertDialog.setCancelable(false); alertDialog.setButton(getString(R.string.ok), quitListener); alertDialog.setIcon(android.R.drawable.ic_dialog_info); alertShowing = true; alertMsg = message; alertDialog.show(); }