List of usage examples for android.app AlertDialog.Builder setView
public void setView(View view)
From source file:com.cerema.cloud2.ui.dialog.ChangelogDialog.java
/** * {@inheritDoc}/*from w ww. j a v a 2 s . co m*/ */ @Override public Dialog onCreateDialog(Bundle savedInstanceState) { /// load the custom view to insert in the dialog, between title and WebView webview = new WebView(getActivity()); webview.loadUrl( "file:///android_res/raw/" + getResources().getResourceEntryName(R.raw.changelog) + ".html"); /// build the dialog AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); Dialog dialog = builder.setView(webview).setIcon(DisplayUtils.getSeasonalIconId()) //.setTitle(R.string.whats_new) .setPositiveButton(R.string.common_ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }).create(); dialog.setCancelable(getArguments().getBoolean(ARG_CANCELABLE)); return dialog; }
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);//from w ww . j a va 2 s.c o m b.setView(inputf); 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);//from w w w . j a v a2s. c om b.setView(inputf); 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.cerema.cloud2.ui.dialog.RenameFileDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { mTargetFile = getArguments().getParcelable(ARG_TARGET_FILE); // Inflate the layout for the dialog LayoutInflater inflater = getActivity().getLayoutInflater(); View v = inflater.inflate(R.layout.edit_box_dialog, null); // Setup layout String currentName = mTargetFile.getFileName(); EditText inputText = ((EditText) v.findViewById(R.id.user_input)); inputText.setText(currentName);//from ww w.ja v a2 s. co m int selectionStart = 0; int extensionStart = mTargetFile.isFolder() ? -1 : currentName.lastIndexOf("."); int selectionEnd = (extensionStart >= 0) ? extensionStart : currentName.length(); if (selectionStart >= 0 && selectionEnd >= 0) { inputText.setSelection(Math.min(selectionStart, selectionEnd), Math.max(selectionStart, selectionEnd)); } inputText.requestFocus(); // Build the dialog AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setView(v).setPositiveButton(R.string.common_ok, this) .setNegativeButton(R.string.common_cancel, this).setTitle(R.string.rename_dialog_title); Dialog d = builder.create(); d.getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE); return d; }
From source file:it.mb.whatshare.Dialogs.java
/** * Shows a dialog containing the code received by goo.gl if any, or an error * message stating that the pairing operation failed. * /*from w w w . j a v a 2s.c o m*/ * @param googl * the pairing code retrieved by goo.gl * @param activity * the caller activity */ public static void onObtainPairingCode(final String googl, final MainActivity activity) { new PatchedDialogFragment() { public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = getBuilder(activity); if (googl != null) { View layout = View.inflate(getContext(), R.layout.pairing_code_dialog, null); TextView message = (TextView) layout.findViewById(R.id.pairingCode); Typeface typeFace = Typeface.createFromAsset(activity.getAssets(), CUSTOM_TYPEFACE_PATH); message.setTypeface(typeFace); message.setText(googl); builder.setView(layout); } else { builder.setMessage(getResources().getString(R.string.code_dialog_fail)); } builder.setPositiveButton(android.R.string.ok, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (googl != null) { Resources res = getResources(); String howManyTotal = res.getQuantityString(R.plurals.added_device, activity.getInboundDevicesCount(), activity.getInboundDevicesCount()); Toast.makeText(getActivity(), res.getString(R.string.device_paired, howManyTotal), Toast.LENGTH_LONG).show(); } } }); return builder.create(); } }.show(activity.getSupportFragmentManager(), "resultCode"); }
From source file:com.fimagena.filepicker.NewFolderFragment.java
@NonNull @Override/* www .ja v a 2 s. co m*/ public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setView(R.layout.dialog_folder_name).setTitle(R.string.new_folder) .setNegativeButton(android.R.string.cancel, null).setPositiveButton(android.R.string.ok, null); final AlertDialog dialog = builder.create(); dialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog1) { final AlertDialog dialog = (AlertDialog) dialog1; final EditText editText = (EditText) dialog.findViewById(R.id.edit_text); Button cancel = dialog.getButton(AlertDialog.BUTTON_NEGATIVE); cancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { dialog.cancel(); } }); final Button ok = dialog.getButton(AlertDialog.BUTTON_POSITIVE); ok.setEnabled(false); // Start disabled ok.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { String itemName = editText.getText().toString(); if (validateName(itemName)) { if (listener != null) listener.onNewFolder(itemName); dialog.dismiss(); } } }); editText.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(final CharSequence s, final int start, final int count, final int after) { } @Override public void onTextChanged(final CharSequence s, final int start, final int before, final int count) { } @Override public void afterTextChanged(final Editable s) { ok.setEnabled(validateName(s.toString())); } }); } }); return dialog; }
From source file:at.ac.tuwien.detlef.fragments.EpisodeListSortDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { settings = Singletons.i().getGpodderSettings(); LayoutInflater inflater = getActivity().getLayoutInflater(); View dialoglayout = inflater.inflate(R.layout.episode_sort_dialog_fragment, null); rbAscending = (RadioButton) dialoglayout.findViewById(R.id.rbAscending); rbDescending = (RadioButton) dialoglayout.findViewById(R.id.rbDescending); rbReleaseDate = (RadioButton) dialoglayout.findViewById(R.id.rbReleaseDate); rbPodcast = (RadioButton) dialoglayout.findViewById(R.id.rbPodcast); rbAscending.setChecked(settings.isAscending()); rbDescending.setChecked(!settings.isAscending()); if (settings.getSortChoice() == EpisodeSortChoice.ReleaseDate) { rbReleaseDate.setChecked(true);//from w w w . j a v a2s . c om rbPodcast.setChecked(false); } else { rbReleaseDate.setChecked(false); rbPodcast.setChecked(true); } AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setView(dialoglayout); builder.setPositiveButton(R.string.button_ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { // ok EpisodeSortChoice choice = EpisodeSortChoice.ReleaseDate; if (rbPodcast.isChecked()) { choice = EpisodeSortChoice.Podcast; } else { if (rbReleaseDate.isChecked()) { choice = EpisodeSortChoice.ReleaseDate; } } // change settings settings.setSortChoice(choice).setAscending(rbAscending.isChecked()); Singletons.i().getGpodderSettingsDAO().writeSettings(settings); mListener.onEpisodeSortDialogPositiveClick(EpisodeListSortDialogFragment.this, rbAscending.isChecked(), choice); } }).setNegativeButton(R.string.button_cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { // cancel mListener.onEpisodeSortDialogNegativeClick(EpisodeListSortDialogFragment.this); } }).setTitle("Sort Options"); return builder.create(); }
From source file:cn.tycoon.lighttrans.fileManager.NewItemFragment.java
@NonNull @Override//w ww . ja v a2s .c o m public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setView(R.layout.dialog_folder_name).setTitle(R.string.new_folder) .setNegativeButton(android.R.string.cancel, null).setPositiveButton(android.R.string.ok, null); final AlertDialog dialog = builder.create(); dialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog1) { final AlertDialog dialog = (AlertDialog) dialog1; final EditText editText = (EditText) dialog.findViewById(R.id.edit_text); Button cancel = dialog.getButton(AlertDialog.BUTTON_NEGATIVE); cancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { dialog.cancel(); } }); final Button ok = dialog.getButton(AlertDialog.BUTTON_POSITIVE); // Start disabled ok.setEnabled(false); ok.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { String itemName = editText.getText().toString(); if (validateName(itemName)) { if (listener != null) { listener.onNewFolder(itemName); } dialog.dismiss(); } } }); editText.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(final CharSequence s, final int start, final int count, final int after) { } @Override public void onTextChanged(final CharSequence s, final int start, final int before, final int count) { } @Override public void afterTextChanged(final Editable s) { ok.setEnabled(validateName(s.toString())); } }); } }); return dialog; }
From source file:com.digi.android.wva.fragments.PreConnectionDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { this.setCancelable(false); final View dialogView = LayoutInflater.from(getActivity()).inflate(R.layout.pre_connection_dialog_layout, null);//ww w . j av a2 s.c o m final PreConnectionDialogListener activity = (PreConnectionDialogListener) getActivity(); if (BuildConfig.DEBUG) { // Make it easier to get through the connection dialog by pre-filling the // authentication with "admin"/"admin". This speeds up development, assuming you're // developing against a WVA with those credentials (or no credentials). EditText username = (EditText) dialogView.findViewById(R.id.auth_username); EditText password = (EditText) dialogView.findViewById(R.id.auth_password); username.setText("admin"); password.setText("admin"); } AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setView(dialogView).setTitle(this.makeTitle()) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String username = ((EditText) dialogView.findViewById(R.id.auth_username)).getText() .toString(); String password = ((EditText) dialogView.findViewById(R.id.auth_password)).getText() .toString(); boolean useHttps = ((CheckBox) dialogView.findViewById(R.id.https_checkbox)).isChecked(); // Turn null username/password into empty strings. Otherwise, we get IllegalArgumentException // for passing null username into setBasicAuth within WVALib code. if (username == null) { username = ""; } if (password == null) { password = ""; } activity.onOkay(ip, username, password, useHttps); } }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { activity.onCancelConnection(); } }); return builder.create(); }
From source file:com.akhbulatov.wordkeeper.ui.dialog.CategoryEditorDialog.java
@NonNull @Override/* w w w . ja v a 2s .com*/ public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); LayoutInflater inflater = getActivity().getLayoutInflater(); builder.setView(inflater.inflate(R.layout.dialog_category_editor, null)).setTitle(mTitleId) .setPositiveButton(mPositiveTextId, (dialog, which) -> mListener.onFinishCategoryEditorDialog(CategoryEditorDialog.this, mPositiveTextId)) .setNegativeButton(mNegativeTextId, (dialog, which) -> dialog.dismiss()); Dialog dialog = builder.create(); // Shows the soft keyboard automatically dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE); return dialog; }