Example usage for android.app AlertDialog.Builder setView

List of usage examples for android.app AlertDialog.Builder setView

Introduction

In this page you can find the example usage for android.app AlertDialog.Builder setView.

Prototype

public void setView(View view) 

Source Link

Document

Set the view to display in that dialog.

Usage

From source file:An.stop.AnstopActivity.java

@Override
protected Dialog onCreateDialog(int id) {
    Dialog dialog;/*from  ww w  . ja  v a  2s . c o  m*/
    switch (id) {
    case ABOUT_DIALOG:
        AlertDialog.Builder aboutBuilder = new AlertDialog.Builder(this);
        aboutBuilder.setMessage(R.string.about_dialog).setCancelable(true).setPositiveButton("Ok",
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        dialog.dismiss();
                    }
                });

        dialog = aboutBuilder.create();
        break;

    case SAVE_DIALOG:
        AlertDialog.Builder saveBuilder = new AlertDialog.Builder(this);
        saveBuilder.setTitle(R.string.save);
        saveBuilder.setMessage(R.string.save_dialog);
        final EditText input = new EditText(this);
        saveBuilder.setView(input);

        saveBuilder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {

                // TODO save!
                Toast toast = Toast.makeText(getApplicationContext(), R.string.saved_succes,
                        Toast.LENGTH_SHORT);
                toast.show();
            }

        });

        saveBuilder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                dialog.dismiss();
            }
        });
        saveBuilder.setCancelable(false);
        dialog = saveBuilder.create();
        break;

    default:
        dialog = null;
    }

    return dialog;
}

From source file:ca.ualberta.slevinsk.gameshow.NumberPickerFragment.java

@NonNull
@Override/*ww w .  jav  a2  s. co  m*/
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle("How many players?");

    builder.setCancelable(false);
    numberPicker = new NumberPicker(getContext());
    numberPicker.setMinValue(2);
    numberPicker.setMaxValue(4);
    numberPicker.setOnValueChangedListener(onPlayerCountChangeListener);

    builder.setView(numberPicker);
    builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {

        }
    });

    return builder.create();
}

From source file:com.android.settings.profiles.ProfilesSettings.java

private void addAppGroup() {
    LayoutInflater inflater = getActivity().getLayoutInflater();
    View content = inflater.inflate(R.layout.profile_name_dialog, null);
    final TextView prompt = (TextView) content.findViewById(R.id.prompt);
    final EditText entry = (EditText) content.findViewById(R.id.name);

    prompt.setText(R.string.profile_appgroup_name_prompt);

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle(R.string.profile_new_appgroup);
    builder.setView(content);

    builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
        @Override/*  ww w .  jav a  2s .com*/
        public void onClick(DialogInterface dialog, int which) {
            String name = entry.getText().toString();
            if (!mProfileManager.notificationGroupExists(name)) {
                NotificationGroup newGroup = new NotificationGroup(name);
                mProfileManager.addNotificationGroup(newGroup);
                mAdapter.refreshAppGroups();
            } else {
                Toast.makeText(getActivity(), R.string.duplicate_appgroup_name, Toast.LENGTH_LONG).show();
            }
        }
    });
    builder.setNegativeButton(android.R.string.cancel, null);

    AlertDialog dialog = builder.create();
    dialog.show();
}

From source file:pl.bcichecki.rms.client.android.dialogs.InboxMessageDetailsDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    if (message == null) {
        throw new IllegalStateException("Message has not been set!");
    }/*from   w w w. j av  a2  s  .c o m*/
    if (messagesRestClient == null) {
        throw new IllegalStateException("MessagesRestClient has not been set!");
    }
    if (inboxMessagesListAdapter == null) {
        throw new IllegalStateException("InboxMessagesListAdapter has not been set!");
    }

    context = getActivity();

    markRead();

    AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity());
    dialogBuilder.setTitle(R.string.dialog_inbox_message_details_title);
    dialogBuilder
            .setView(getActivity().getLayoutInflater().inflate(R.layout.dialog_inbox_message_details, null));
    dialogBuilder.setNeutralButton(R.string.dialog_inbox_message_details_reply,
            new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    MessageRecipent messageRecipent = new MessageRecipent();
                    messageRecipent.setRecipent(message.getSender());
                    HashSet<MessageRecipent> messageRecipents = new HashSet<MessageRecipent>();
                    messageRecipents.add(messageRecipent);
                    Message replyMessage = new Message();
                    replyMessage.setSubject(
                            getString(R.string.dialog_inbox_message_details_re) + ": " + message.getSubject());
                    replyMessage.setRecipents(messageRecipents);

                    Log.d(getTag(), "Starting reply message activity...");
                    Intent newMessageIntent = new Intent(context, NewMessageActivity.class);
                    newMessageIntent.putExtra(MESSAGE_EXTRA, replyMessage);
                    startActivityForResult(newMessageIntent, REQUEST_CODE_SEND_MESSAGE);
                }
            });
    dialogBuilder.setPositiveButton(R.string.general_close, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            // Nothing to do...
        }
    });

    AlertDialog dialog = dialogBuilder.create();
    dialog.setOnShowListener(new DialogInterface.OnShowListener() {

        @Override
        public void onShow(DialogInterface dialog) {
            TextView subjectTextView = (TextView) ((AlertDialog) dialog)
                    .findViewById(R.id.dialog_inbox_message_details_subject_text);
            subjectTextView.setText(message.getSubject());

            StringBuilder sender = new StringBuilder();
            if (message.getSender().getAddress() != null
                    && message.getSender().getAddress().getFirstName() != null
                    && message.getSender().getAddress().getLastName() != null) {
                sender.append(message.getSender().getAddress().getFirstName()).append(" ")
                        .append(message.getSender().getAddress().getLastName());
            } else {
                sender.append(message.getSender().getUsername());
            }

            TextView senderTextView = (TextView) ((AlertDialog) dialog)
                    .findViewById(R.id.dialog_inbox_message_details_sender_text);
            senderTextView.setText(sender.toString());

            TextView receivedDataTextView = (TextView) ((AlertDialog) dialog)
                    .findViewById(R.id.dialog_inbox_message_details_received_date_text);
            receivedDataTextView
                    .setText(AppUtils.getFormattedDateAsString(message.getDate(), Locale.getDefault()));

            TextView contentTextView = (TextView) ((AlertDialog) dialog)
                    .findViewById(R.id.dialog_inbox_message_details_content_text);
            contentTextView.setText(message.getContent());
        }
    });

    return dialog;
}

From source file:gxu.software_engineering.market.android.ui.RegisterBoxFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), android.R.style.Theme_Holo_Dialog);
    final View v = getActivity().getLayoutInflater().inflate(R.layout.register, null);
    builder.setIcon(R.drawable.social_add_person).setTitle(R.string.register);
    return builder.setView(v).setNegativeButton(R.string.no, null)
            .setPositiveButton(R.string.ok, new OnClickListener() {
                @Override//  w  w  w . j  ava2  s  . com
                public void onClick(DialogInterface dialog, int which) {
                    String[] data = data(v);
                    ContentValues user = null;
                    try {
                        user = new Post2Server().execute(data).get();
                    } catch (Exception e) {
                        Log.wtf("register error!", e);
                        Toast.makeText(getActivity(), R.string.register_fail, Toast.LENGTH_SHORT).show();
                    }
                    Toast.makeText(getActivity(), R.string.register_ok, Toast.LENGTH_SHORT).show();
                    if (user != null) {
                        getActivity().getContentResolver().insert(Uri.parse(C.BASE_URI + C.USERS), user);
                    } else {
                        Toast.makeText(getActivity(), R.string.register_fail, Toast.LENGTH_SHORT).show();
                    }
                }
            }).create();
}

From source file:com.doomy.padlock.MainActivity.java

private void openAboutDialog() {
    LayoutInflater mLayoutInflater = LayoutInflater.from(this);
    View mView = mLayoutInflater.inflate(R.layout.view_about, null);

    ImageView mImageViewMrDoomy = (ImageView) mView.findViewById(R.id.imageViewMrDoomy);
    ImageView mImageViewStudio = (ImageView) mView.findViewById(R.id.imageViewStudio);
    ImageView mImageViewGitHub = (ImageView) mView.findViewById(R.id.imageViewGitHub);
    Drawable mMrDoomy = mImageViewMrDoomy.getDrawable();
    Drawable mStudio = mImageViewStudio.getDrawable();
    Drawable mGitHub = mImageViewGitHub.getDrawable();
    mMrDoomy.setColorFilter(getResources().getColor(R.color.orangeDark), PorterDuff.Mode.SRC_ATOP);
    mStudio.setColorFilter(getResources().getColor(R.color.orange), PorterDuff.Mode.SRC_ATOP);
    mGitHub.setColorFilter(getResources().getColor(R.color.greyMaterialDark), PorterDuff.Mode.SRC_ATOP);

    mImageViewGitHub.setOnClickListener(new View.OnClickListener() {
        @Override//w w w  .  j  a  v a  2 s . co  m
        public void onClick(View v) {
            Intent mIntent = new Intent();
            mIntent.setAction(Intent.ACTION_VIEW);
            mIntent.addCategory(Intent.CATEGORY_BROWSABLE);
            mIntent.setData(Uri.parse(getString(R.string.url)));
            startActivity(mIntent);
        }
    });

    AlertDialog.Builder mAlertDialog = new AlertDialog.Builder(MainActivity.this, R.style.DialogTheme);

    mAlertDialog.setTitle(getString(R.string.about));
    mAlertDialog.setView(mView);
    mAlertDialog.setPositiveButton(getString(R.string.okay), new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });
    mAlertDialog.show();
}

From source file:com.dsi.ant.antplus.pluginsampler.Dialog_ProgressWaiter.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
    View detailsView = inflater.inflate(R.layout.dialog_progresswaiter, null);
    builder.setView(detailsView);

    textView_status = (TextView) detailsView.findViewById(R.id.textView_Status);
    setStatus(actionDescription + "...");

    return builder.create();
}

From source file:ch.pec0ra.mobilityratecalculator.ItineraryDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    // Get the layout inflater
    LayoutInflater inflater = getActivity().getLayoutInflater();
    final View v = inflater.inflate(R.layout.itinerary_dialog, null);

    // Inflate and set the layout for the dialog
    // Pass null as the parent view because its going in the dialog layout
    builder.setView(v).setTitle(getString(R.string.find_itinerary))
            // Add action buttons
            .setPositiveButton(R.string.calculate_distance, new DialogInterface.OnClickListener() {
                @Override//from w  ww .  j ava 2 s  . c o  m
                public void onClick(final DialogInterface dialog, int id) {
                    final String from = ((TextView) v.findViewById(R.id.itinerary_from)).getText().toString();
                    final String to = ((TextView) v.findViewById(R.id.itinerary_to)).getText().toString();
                    final boolean isTwoWay = ((CheckBox) v.findViewById(R.id.two_way_checkbox)).isChecked();
                    mListener.onDialogPositiveClick(from, to, isTwoWay);
                }
            }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    ItineraryDialog.this.getDialog().cancel();
                }
            });
    return builder.create();

}

From source file:ca.farrelltonsolar.classic.IPAddressDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    // Use the Builder class for convenient dialog construction
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    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
    View view = inflater.inflate(R.layout.dialog_static_address, null);
    builder.setView(view);
    EditText edAddress = (EditText) view.findViewById(R.id.ipAddress);
    edAddress.setKeyListener(IPAddressKeyListener.getInstance());

    builder.setPositiveButton(R.string.ApplyButton, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            String port = ((EditText) getDialog().findViewById(R.id.port)).getText().toString();
            String edAddress = ((EditText) getDialog().findViewById(R.id.ipAddress)).getText().toString();
            if (!port.isEmpty() && !edAddress.isEmpty()) {
                if (IPV4_PATTERN.matcher(edAddress).matches()) {
                    ChargeControllerInfo cc = new ChargeControllerInfo(edAddress, Integer.valueOf(port), true);
                    cc.setIsReachable(false);
                    LocalBroadcastManager broadcaster = LocalBroadcastManager
                            .getInstance(IPAddressDialog.this.getActivity());
                    Intent pkg = new Intent(Constants.CA_FARRELLTONSOLAR_CLASSIC_ADD_CHARGE_CONTROLLER);
                    pkg.putExtra("ChargeController", GSON.toJson(cc));
                    pkg.putExtra("ForceRefresh", true);
                    broadcaster.sendBroadcast(pkg);
                    dialog.dismiss();// w w  w  .jav  a2s .c  o m
                }
            }
        }
    }).setNegativeButton(R.string.CancelButton, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            // User cancelled the dialog
        }
    });
    // Create the AlertDialog object and return it
    return builder.create();
}

From source file:de.awisus.refugeeaidleipzig.views.profile.FragmentEditOffer.java

@NonNull
@Override//  ww w .  j  ava 2 s . co m
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    View view = getActivity().getLayoutInflater().inflate(R.layout.fragment_edit_offer, null);

    builder.setView(view);
    Dialog dialog = builder.create();

    initView(view);

    if (angebot == null) {
        forNewOffer(dialog);
        setListeners(view, true);
    } else {
        forExistingOffer(dialog);
        setListeners(view, false);
    }

    requestPermissions();
    return dialog;
}