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:net.eledge.android.europeana.gui.dialog.NameInputDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    LayoutInflater inflater = getActivity().getLayoutInflater();

    View view = inflater.inflate(R.layout.dialog_nameinput, null);
    TextView text = (TextView) view.findViewById(R.id.dialog_nameinput_textview);
    if (resText != -1) {
        text.setText(resText);/*from  w  w  w.  ja v a2  s  .  c  o m*/
    } else {
        text.setVisibility(View.GONE);
    }
    mInput = (EditText) view.findViewById(R.id.dialog_nameinput_edittext);
    mInput.setHint(resInput);
    mInput.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            //ignore
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            //ignore
        }

        @Override
        public void afterTextChanged(Editable s) {
            mDialog.getButton(Dialog.BUTTON_POSITIVE).setEnabled(StringUtils.isNotBlank(s.toString()));
        }
    });

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setView(view);
    if (resTitle != -1) {
        builder.setTitle(resTitle);
    }
    builder.setPositiveButton(resPositiveButton, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int id) {
            String input = mInput.getText().toString();
            if (StringUtils.isNotBlank(input)) {
                mListener.positiveResponse(input);
                NameInputDialog.this.dismiss();
            }
        }
    });
    builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int id) {
            mListener.negativeResponse();
            mDialog.dismiss();
        }
    });
    mDialog = builder.create();
    mDialog.setCanceledOnTouchOutside(false);
    mDialog.setCancelable(false);
    return mDialog;
}

From source file:com.cerema.cloud2.ui.dialog.SharePasswordDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    mFile = getArguments().getParcelable(ARG_FILE);
    mCreateShare = getArguments().getBoolean(ARG_CREATE_SHARE, false);

    // Inflate the layout for the dialog
    LayoutInflater inflater = getActivity().getLayoutInflater();
    View v = inflater.inflate(R.layout.password_dialog, null);

    // Setup layout
    EditText inputText = ((EditText) v.findViewById(R.id.share_password));
    inputText.setText("");
    inputText.requestFocus();/*from ww  w.  j  a va  2s. c  o  m*/

    // Build the dialog
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(),
            R.style.Theme_ownCloud_Dialog_NoButtonBarStyle);
    builder.setView(v).setPositiveButton(R.string.common_ok, this)
            .setNegativeButton(R.string.common_cancel, this).setTitle(R.string.share_link_password_title);
    Dialog d = builder.create();
    d.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
    return d;
}

From source file:com.akhbulatov.wordkeeper.ui.dialog.WordEditorDialog.java

@NonNull
@SuppressLint("InflateParams")
@Override/*from  w ww  . j a v  a 2s.c  o  m*/
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    LayoutInflater inflater = getActivity().getLayoutInflater();

    builder.setView(inflater.inflate(R.layout.dialog_word_editor, null)).setTitle(mTitleId)
            .setPositiveButton(mPositiveTextId,
                    (dialog, which) -> mListener.onFinishWordEditorDialog(WordEditorDialog.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;
}

From source file:com.aniruddhc.acemusic.player.Dialogs.LicensesDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    parentActivity = getActivity();/*from   w  w  w. j ava  2s.  co m*/
    dialogFragment = (DialogFragment) getFragmentManager().findFragmentByTag("licensesDialog");

    rootView = (View) parentActivity.getLayoutInflater().inflate(R.layout.licenses_dialog_layout, null);

    creativeCommonsLink = (TextView) rootView.findViewById(R.id.creative_commons_link);
    creativeCommonsLink.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    creativeCommonsLink.setText(Html.fromHtml(
            "<a href=\"http://creativecommons.org/licenses/by-sa/3.0/legalcode\">Creative Commons ShareALike 3.0 License</a> "));
    creativeCommonsLink.setMovementMethod(LinkMovementMethod.getInstance());

    creativeCommonsInfo = (TextView) rootView.findViewById(R.id.licenses_text);
    creativeCommonsInfo.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

    //Set the dialog title.
    builder.setTitle(R.string.licenses);
    builder.setView(rootView);
    builder.setPositiveButton(R.string.done, new OnClickListener() {

        @Override
        public void onClick(DialogInterface arg0, int arg1) {
            dialogFragment.dismiss();
            getActivity().finish();

        }

    });

    return builder.create();
}

From source file:appocorrencias.com.appocorrencias.Activitys.DelayedProgressDialog.java

@NonNull
@SuppressLint("InflateParams")
@Override/*  w  ww  . j  a  va 2 s  .  co  m*/
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    LayoutInflater inflater = getActivity().getLayoutInflater();

    builder.setView(inflater.inflate(R.layout.activity_process_dialog, null));
    return builder.create();
}

From source file:com.esri.squadleader.view.GoToMgrsDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    if (null != listener) {
        LayoutInflater inflater = getActivity().getLayoutInflater();
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        final View inflatedView = inflater.inflate(R.layout.go_to_mgrs, null);
        builder.setView(inflatedView);
        builder.setTitle(getString(R.string.go_to_mgrs));
        builder.setNegativeButton(R.string.cancel, null);
        builder.setPositiveButton(R.string.go_to_mgrs, new DialogInterface.OnClickListener() {

            public void onClick(DialogInterface dialog, int which) {
                View view = inflatedView.findViewById(R.id.editText_mgrs);
                if (null != view && view instanceof EditText) {
                    String mgrs = ((EditText) view).getText().toString();
                    if (null != mgrs) {
                        listener.beforePanToMgrs(mgrs);
                        if (null == listener.getMapController().panTo(mgrs)) {
                            Toast.makeText(getActivity(), "Invalid MGRS string: " + mgrs, Toast.LENGTH_LONG)
                                    .show();
                            listener.onPanToMgrsError(mgrs);
                        }/*from ww  w  .  ja  v  a  2  s .  c  o  m*/
                    }
                }
            }
        });
        return builder.create();
    } else {
        return null;
    }
}

From source file:com.dgsd.android.ShiftTracker.Fragment.HoursAndIncomeSummaryFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    View v = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_hour_and_income_summary, null);

    mMonth = (TextView) v.findViewById(R.id.month);
    mThreeMonth = (TextView) v.findViewById(R.id.three_months);
    mSixMonth = (TextView) v.findViewById(R.id.six_months);
    mNineMonth = (TextView) v.findViewById(R.id.nine_months);
    mThisYear = (TextView) v.findViewById(R.id.year);

    AlertDialog.Builder b = new AlertDialog.Builder(getActivity());
    b.setView(v);

    Time time = new Time();
    time.setJulianDay(mJulianDay);/*from   w  w w .  j  av  a  2 s. co m*/

    b.setTitle(DateFormat.getDateFormat(getActivity()).format(time.toMillis(true)));

    Dialog d = b.create();
    d.setCanceledOnTouchOutside(true);

    return d;
}

From source file:com.balch.auctionbrowser.auction.AuctionDetailDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

    LayoutInflater inflater = getActivity().getLayoutInflater();
    builder.setView(inflater.inflate(R.layout.auction_detail_dialog, null));
    return builder.create();
}

From source file:com.dnielfe.manager.dialogs.DirectoryInfoDialog.java

public Dialog onCreateDialog(final Bundle savedInstanceState) {
    final Activity activity = this.getActivity();
    mView = activity.getLayoutInflater().inflate(R.layout.dialog_directory_info, null);
    final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
    builder.setTitle(R.string.dir_info);
    builder.setView(mView);
    builder.setNeutralButton(R.string.ok, null);
    return builder.create();
}

From source file:com.aniruddhc.acemusic.player.Dialogs.AddToPlaylistDialog.java

public void showNewPlaylistDialog() {
    View dialogView = getActivity().getLayoutInflater().inflate(R.layout.add_new_playlist_dialog_layout, null);
    final EditText newPlaylistEditText = (EditText) dialogView.findViewById(R.id.new_playlist_name_text_field);
    newPlaylistEditText.setTypeface(TypefaceHelper.getTypeface(getActivity(), "RobotoCondensed-Light"));
    newPlaylistEditText.setPaintFlags(// w w  w .ja  v  a2s  .  c o  m
            newPlaylistEditText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle(R.string.new_playlist);
    builder.setView(dialogView);
    builder.setPositiveButton(R.string.ok, new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            //Retrieve the name of the new playlist.
            String playlistName = newPlaylistEditText.getText().toString();
            AsyncCreateNewPlaylistTask task = new AsyncCreateNewPlaylistTask(mContext, playlistName, ARTIST,
                    ALBUM, SONG, GENRE, ALBUM_ARTIST, ADD_TYPE);
            task.execute();
            dialog.dismiss();

        }

    });

    builder.setNegativeButton(R.string.cancel, new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();

        }

    });

    builder.create().show();
}