Refine search
private void showDownloadDialog() { builder = new AlertDialog.Builder(mContext); final LayoutInflater inflater = LayoutInflater.from(mContext); View v = inflater.inflate(R.layout.progress_update, null); mProgress = (ProgressBar) v.findViewById(R.id.progress); updatePercentTextView = (TextView) v.findViewById(R.id.updatePercentTextView); updateCurrentTextView = (TextView) v.findViewById(R.id.updateCurrentTextView); updateCurrentTextView.setText(prepareDownloadingTextViewString); updateTotalTextView = (TextView) v.findViewById(R.id.updateTotalTextView); // builder.setCustomTitle(inflater.inflate(R.layout.progress_update_title, null)); builder.setTitle(downloadTitle); builder.setView(v); builder.setNegativeButton(downloadCancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); interceptFlag = true; } }); progressDialog = builder.create(); progressDialog.show(); }
private void initSearch() { AlertDialog.Builder searchDialog = new AlertDialog.Builder(this); LayoutInflater inflater = this.getLayoutInflater(); searchDialog.setTitle("Search Photos"); searchDialog.setMessage("Specify tag and value..."); // R.layout.search_dialog is my custom layour, it displays fine, it works. View dialogView = inflater.inflate(R.layout.search_dialog, null); searchDialog.setView(dialogView); EditText tagText = (EdiText) dialogView.findViewById(R.id.tagField); searchDialog.setPositiveButton( ... ) ... AlertDialog myAlert = searchDialog.create(); //returns an AlertDialog from a Builder. myAlert.show(); }
String names[] ={"A","B","C","D"}; AlertDialog.Builder alertDialog = new AlertDialog.Builder(MainActivity.this); LayoutInflater inflater = getLayoutInflater(); View convertView = (View) inflater.inflate(R.layout.custom, null); alertDialog.setView(convertView); alertDialog.setTitle("List"); ListView lv = (ListView) convertView.findViewById(R.id.listView1); ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,names); lv.setAdapter(adapter); alertDialog.show();
@Nullable @Override public View onCreateView(final LayoutInflater inflater, @Nullable final ViewGroup container, @Nullable final Bundle savedInstanceState) { final View view = inflater.inflate(R.layout.notes_fragment, container, false); // Find the clear button and wire the click listener to call the clear notes updatable view.findViewById(R.id.clear).setOnClickListener(v -> notesStore.clearNotes()); // Find the add button and wire the click listener to show a dialog that in turn calls the add // note from text from the notes store when adding notes view.findViewById(R.id.add).setOnClickListener(v -> { final EditText editText = new EditText(v.getContext()); editText.setId(R.id.edit); new AlertDialog.Builder(v.getContext()) .setTitle(R.string.add_note) .setView(editText) .setPositiveButton(R.string.add, (d, i) -> { notesStore.insertNoteFromText(editText.getText().toString()); }) .create().show(); }); // Setup the recycler view using the repository adapter recyclerView = (RecyclerView) view.findViewById(R.id.result); recyclerView.setAdapter(adapter); recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); final ImageView imageView = (ImageView) view.findViewById(R.id.background); updatable = () -> backgroundRepository.get().ifSucceededSendTo(imageView::setImageBitmap); return view; }
final AlertDialog.Builder builder = new AlertDialog.Builder(activity); builder.setTitle(activity.getString(R.string.settings_import_activate_account_header)); builder.setView(scrollView); builder.setPositiveButton(activity.getString(R.string.okay_action), new DialogInterface.OnClickListener() { @Override builder.setNegativeButton(activity.getString(R.string.cancel_action), new DialogInterface.OnClickListener() { @Override mDialog = builder.create(); View layout = mDialog.getLayoutInflater().inflate(R.layout.accounts_password_prompt, scrollView); TextView intro = layout.findViewById(R.id.password_prompt_intro); String serverPasswords = activity.getResources().getQuantityString( R.plurals.settings_import_server_passwords, mOutgoingPasswordView = layout.findViewById(R.id.outgoing_server_password); mOutgoingPasswordView.addTextChangedListener(this); mUseIncomingView = layout.findViewById(R.id.use_incoming_server_password); mDialog.show();
private void showLinkDialog() { final int start = knife.getSelectionStart(); final int end = knife.getSelectionEnd(); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setCancelable(false); View view = getLayoutInflater().inflate(R.layout.dialog_link, null, false); final EditText editText = (EditText) view.findViewById(R.id.edit); builder.setView(view); builder.setTitle(R.string.dialog_title); builder.setPositiveButton(R.string.dialog_button_ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String link = editText.getText().toString().trim(); if (TextUtils.isEmpty(link)) { return; } // When KnifeText lose focus, use this method knife.link(link, start, end); } }); builder.setNegativeButton(R.string.dialog_button_cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // DO NOTHING HERE } }); builder.create().show(); }
/** * Gets a pair consisting of a dialog and the {@link TrackSelectionView} that will be shown by it. * * @param activity The parent activity. * @param title The dialog's title. * @param trackSelector The track selector. * @param rendererIndex The index of the renderer. * @return The dialog and the {@link TrackSelectionView} that will be shown by it. */ public static Pair<AlertDialog, TrackSelectionView> getDialog( Activity activity, CharSequence title, DefaultTrackSelector trackSelector, int rendererIndex) { AlertDialog.Builder builder = new AlertDialog.Builder(activity); // Inflate with the builder's context to ensure the correct style is used. LayoutInflater dialogInflater = LayoutInflater.from(builder.getContext()); View dialogView = dialogInflater.inflate(R.layout.exo_track_selection_dialog, null); final TrackSelectionView selectionView = dialogView.findViewById(R.id.exo_track_selection_view); selectionView.init(trackSelector, rendererIndex); Dialog.OnClickListener okClickListener = (dialog, which) -> selectionView.applySelection(); AlertDialog dialog = builder .setTitle(title) .setView(dialogView) .setPositiveButton(android.R.string.ok, okClickListener) .setNegativeButton(android.R.string.cancel, null) .create(); return Pair.create(dialog, selectionView); }
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this); // ...Irrelevant code for customizing the buttons and title LayoutInflater inflater = this.getLayoutInflater(); View dialogView = inflater.inflate(R.layout.alert_label_editor, null); dialogBuilder.setView(dialogView); EditText editText = (EditText) dialogView.findViewById(R.id.label_field); editText.setText("test label"); AlertDialog alertDialog = dialogBuilder.create(); alertDialog.show();
LayoutInflater linf = LayoutInflater.from(this); final View inflator = linf.inflate(R.layout.twoinputs, null); AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle("Tilte"); alert.setMessage("Message"); alert.setView(inflator); final EditText et1 = (EditText) inflator.findViewById(R.id.editText1); final EditText et2 = (EditText) inflator.findViewById(R.id.editText2); alert.setPositiveButton("ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String s1=et1.getText().toString(); String s2=et2.getText().toString(); //do operations using s1 and s2 here... } }); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }); alert.show();
CustomAdapter adapter = (CustomAdapter) parent.getAdapter(); RowData row = adapter.getItem(position); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(row.mItem); builder.setMessage(row.mDescription + " -> " + position ); builder.setPositiveButton("ok", null); builder.show(); convertView = mInflater.inflate(R.layout.custom_row, null); holder = new ViewHolder(convertView); convertView.setTag(holder); holder = (ViewHolder) convertView.getTag(); item = holder.getItem(); item.setText(rowData.mItem); description = (TextView) mRow.findViewById(R.id.description);
private void add() { LayoutInflater inflater=getActivity().getLayoutInflater(); View addView=inflater.inflate(R.layout.add_edit, null); AlertDialog.Builder builder=new AlertDialog.Builder(getActivity()); builder.setTitle(R.string.add_title).setView(addView) .setPositiveButton(R.string.ok, this) .setNegativeButton(R.string.cancel, null).show(); }
LayoutInflater factory = LayoutInflater.from(this); final View deleteDialogView = factory.inflate(R.layout.mylayout, null); final AlertDialog deleteDialog = new AlertDialog.Builder(this).create(); deleteDialog.setView(deleteDialogView); deleteDialogView.findViewById(R.id.yes).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { //your business logic deleteDialog.dismiss(); } }); deleteDialogView.findViewById(R.id.no).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { deleteDialog.dismiss(); } }); deleteDialog.show();
View promptView = layoutInflater.inflate(R.layout.prompt, null); final AlertDialog alertD = new AlertDialog.Builder(this).create(); EditText userInput = (EditText) promptView.findViewById(R.id.userInput); Button btnAdd1 = (Button) promptView.findViewById(R.id.btnAdd1); Button btnAdd2 = (Button) promptView.findViewById(R.id.btnAdd2); alertD.setView(promptView); alertD.show();
LayoutInflater inflater = getLayoutInflater(); View dialoglayout = inflater.inflate(R.layout.dialog_layout, null); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setView(dialoglayout); builder.show();
final View bannerView = View.inflate(activity, R.layout.dialog_title, null); bannerView.setSelected(true); TextView titleView = bannerView.findViewById(R.id.itemTitleView); titleView.setText(selectedItem.getName()); detailsView.setVisibility(View.GONE); new AlertDialog.Builder(activity) .setCustomTitle(bannerView) .setItems(commands, actions) .create() .show();
View myview = inflater.inflate(R.layout.YOUR_CUSTOM_LAYOUT, null); builder.setNeutralButton(android.R.string.cancel, null); builder.setView(myview); AlertDialog dialog = builder.create(); dialog.show(); Button neutral_button = dialog.getButton(DialogInterface.BUTTON_NEUTRAL); Button positive_button = dialog.getButton(DialogInterface.BUTTON_POSITIVE);
public class MyDialogFragment extends DialogFragment { @Override public Dialog onCreateDialog(Bundle savedInstanceState) { LayoutInflater inflater = getActivity().getLayoutInflater(); View view = inflater.inflate(R.layout.dialog_layout, null, false); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()) .setTitle("in case you want use a title").setView(view); AlertDialog alert = builder.create(); // alert.setCancelable(false); <-- dont' use that instead use bellow approach setCancelable(false); <- press back button not cancel dialog, this one works fine alert.setCanceledOnTouchOutside(false); <- to cancel outside touch return alert; }
private Dialog myTextDialog() { final View layout = View.inflate(this, R.layout.myDialog, null); final EditText savedText = ((EditText) layout.findViewById(R.id.myEditText)); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setIcon(0); builder.setPositiveButton("Save", new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { String myTextString = savedText.getText().toString().trim(); } }); builder.setView(layout); return builder.create(); }
AlertDialog.Builder builder = new AlertDialog.Builder(context) .setTitle("My title") .setMessage("Enter password"); final FrameLayout frameView = new FrameLayout(context); builder.setView(frameView); final AlertDialog alertDialog = builder.create(); LayoutInflater inflater = alertDialog.getLayoutInflater(); View dialoglayout = inflater.inflate(R.layout.simple_password, frameView); alertDialog.show();
AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Title"); // Set up the input final EditText input = new EditText(this); // Specify the type of input expected; this, for example, sets the input as a password, and will mask the text input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); builder.setView(input); // Set up the buttons builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { m_Text = input.getText().toString(); } }); builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); builder.show();