Example usage for android.support.v4.app AlertDialog.Builder setView

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

Introduction

In this page you can find the example usage for android.support.v4.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:de.mkrtchyan.recoverytools.SettingsFragment.java

public static void showChangelog(Context AppContext) {
    AlertDialog.Builder dialog = new AlertDialog.Builder(AppContext);
    dialog.setTitle(R.string.changelog);
    WebView changes = new WebView(AppContext);
    changes.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
    changes.setWebViewClient(new WebViewClient());
    changes.loadUrl(Constants.CHANGELOG_URL);
    changes.clearCache(true);/*from w w w  .  ja va  2s . c o m*/
    dialog.setView(changes);
    dialog.show();
}

From source file:org.quantumbadger.redreader.activities.PostListingActivity.java

public static void onSearchPosts(final PostListingController controller, final Activity activity) {

    final AlertDialog.Builder alertBuilder = new AlertDialog.Builder(activity);
    final LinearLayout layout = (LinearLayout) activity.getLayoutInflater().inflate(R.layout.dialog_editbox);
    final EditText editText = (EditText) layout.findViewById(R.id.dialog_editbox_edittext);

    editText.requestFocus();/*from   w w  w. j a v  a 2s  .  c  o  m*/

    alertBuilder.setView(layout);
    alertBuilder.setTitle(R.string.action_search);

    alertBuilder.setPositiveButton(R.string.action_search, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {

            final String query = editText.getText().toString().toLowerCase().trim();

            final RedditURLParser.SearchPostListURL url;

            if (controller != null && controller.isSubreddit()) {
                url = RedditURLParser.SearchPostListURL.build(controller.subredditCanonicalName(), query);
            } else {
                url = RedditURLParser.SearchPostListURL.build(null, query);
            }

            final Intent intent = new Intent(activity, PostListingActivity.class);
            intent.setData(url.generateJsonUri());
            activity.startActivity(intent);
        }
    });

    alertBuilder.setNegativeButton(R.string.dialog_cancel, null);

    final AlertDialog alertDialog = alertBuilder.create();
    alertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
    alertDialog.show();
}

From source file:org.lol.reddit.activities.PostListingActivity.java

public static void onSearchPosts(final PostListingController controller, final Activity activity) {

    final AlertDialog.Builder alertBuilder = new AlertDialog.Builder(activity);
    final LinearLayout layout = (LinearLayout) activity.getLayoutInflater().inflate(R.layout.dialog_editbox);
    final EditText editText = (EditText) layout.findViewById(R.id.dialog_editbox_edittext);

    editText.requestFocus();//from  www. jav  a 2 s  .  co  m

    alertBuilder.setView(layout);
    alertBuilder.setTitle(R.string.action_search);

    alertBuilder.setPositiveButton(R.string.action_search, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {

            final String query = editText.getText().toString().toLowerCase().trim();

            final SearchPostListURL url;

            if (controller != null && controller.isSubreddit()) {
                url = SearchPostListURL.build(controller.subredditCanonicalName(), query);
            } else {
                url = SearchPostListURL.build(null, query);
            }

            final Intent intent = new Intent(activity, PostListingActivity.class);
            intent.setData(url.generateJsonUri());
            activity.startActivity(intent);
        }
    });

    alertBuilder.setNegativeButton(R.string.dialog_cancel, null);

    final AlertDialog alertDialog = alertBuilder.create();
    alertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
    alertDialog.show();
}

From source file:com.stepstone.stepper.sample.step.DelayedTransitionStepFragmentSample.java

@Override
@UiThread/* w  w  w.j a  v a  2  s  .  c  om*/
public void onNextClicked(final StepperLayout.OnNextClickedCallback callback) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setView(R.layout.dialog_loader);
    builder.setCancelable(false);
    dialog = builder.show();
    new Handler().postDelayed(new Runnable() {
        @Override
        public void run() {
            dialog.dismiss();
            callback.goToNextStep();
        }
    }, 2000L);
}

From source file:com.sonnychen.aviationhk.MainActivity.java

public void showBookings() {
    if (!TextUtils.isEmpty(BaseApplication.HKACPassword)) {
        launchBookingViewer();//from   w  w w  . j  a  va  2  s. co  m
        return;
    }

    View promptsView = LayoutInflater.from(this).inflate(R.layout.simple_password_prompt, null);
    final EditText userInput = (EditText) promptsView.findViewById(R.id.editTextDialogUserInput);

    final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
    alertDialogBuilder.setView(promptsView);
    // set dialog message
    alertDialogBuilder.setCancelable(true)
            .setPositiveButton(R.string.go, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    /** DO THE METHOD HERE WHEN PROCEED IS CLICKED*/
                    String password = (userInput.getText()).toString();

                    /** CHECK FOR USER'S INPUT **/
                    if (!TextUtils.isEmpty(password)) {
                        BaseApplication.HKACPassword = password;
                        SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
                        SharedPreferences.Editor editor = settings.edit();
                        editor.putString("HKACPassword", BaseApplication.HKACPassword);
                        editor.apply();

                        launchBookingViewer();
                    } else {
                        AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
                        builder.setTitle(R.string.error);
                        builder.setMessage(R.string.pdf_password_is_required);
                        builder.create().show();
                    }
                }
            }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    dialog.dismiss();
                }

            }

    );

    alertDialogBuilder.create().show();
}

From source file:com.hacktx.android.activities.MainActivity.java

private void displaySlackAlert() {
    if (isSlackInstalled() && !UserStateStore.getSlackAlertShown(this)) {
        mMetricsManager.logEvent(R.string.analytics_event_slack_dialog_show, null);

        final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
        LayoutInflater inflater = this.getLayoutInflater();
        View dialogView = inflater.inflate(R.layout.dialog_slack, null);
        dialogBuilder.setView(dialogView);

        final AlertDialog dialog = dialogBuilder.create();
        dialog.show();//w  w w .j  a va  2  s  . c  om

        dialogView.findViewById(R.id.btn_slack_yes).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mMetricsManager.logEvent(R.string.analytics_event_slack_dialog_disable_notif, null);
                UserStateStore.setAnnouncementNotificationsEnabled(MainActivity.this, false);
                dialog.dismiss();
            }
        });

        dialogView.findViewById(R.id.btn_slack_no).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mMetricsManager.logEvent(R.string.analytics_event_slack_dialog_no, null);
                dialog.dismiss();
            }
        });

        UserStateStore.setSlackAlertShown(MainActivity.this, true);
    }
}

From source file:org.mozilla.focus.fragment.DownloadDialogFragment.java

public AlertDialog onCreateDialog(Bundle bundle) {
    final String fileName = getArguments().getString("fileName");
    final Download pendingDownload = getArguments().getParcelable("download");

    final AlertDialog.Builder builder = new AlertDialog.Builder(getContext(), R.style.DialogStyle);
    builder.setCancelable(true);/*from w  w w.  ja v  a  2s. c  om*/
    builder.setTitle(getString(R.string.download_dialog_title));

    final LayoutInflater inflater = getActivity().getLayoutInflater();
    final View dialogView = inflater.inflate(R.layout.download_dialog, null);
    builder.setView(dialogView);

    final ImageView downloadDialogIcon = (ImageView) dialogView.findViewById(R.id.download_dialog_icon);
    final TextView downloadDialogMessage = (TextView) dialogView.findViewById(R.id.download_dialog_file_name);
    final Button downloadDialogCancelButton = (Button) dialogView.findViewById(R.id.download_dialog_cancel);
    final Button downloadDialogDownloadButton = (Button) dialogView.findViewById(R.id.download_dialog_download);
    final TextView downloadDialogWarningMessage = (TextView) dialogView
            .findViewById(R.id.download_dialog_warning);

    downloadDialogIcon.setImageResource(R.drawable.ic_download);
    downloadDialogMessage.setText(fileName);
    downloadDialogCancelButton.setText(getString(R.string.download_dialog_action_cancel));
    downloadDialogDownloadButton.setText(getString(R.string.download_dialog_action_download));
    downloadDialogWarningMessage
            .setText(getSpannedTextFromHtml(R.string.download_dialog_warning, R.string.app_name));

    final AlertDialog alert = builder.create();

    setButtonOnClickListener(downloadDialogCancelButton, pendingDownload, false);
    setButtonOnClickListener(downloadDialogDownloadButton, pendingDownload, true);

    return alert;
}

From source file:org.wheelmap.android.fragment.LoginDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    //TODO check if already logged in
    //TODO and show logout dialog if already logged in
    AlertDialog.Builder builder = new AlertDialog.Builder(getSupportActivity());
    builder.setOnCancelListener(this);

    View view = LayoutInflater.from(getSupportActivity()).inflate(R.layout.fragment_dialog_login, null);
    builder.setView(view);

    Dialog d = builder.create();//w  ww . j  a v a  2s  .  c  om
    return d;

}

From source file:com.jadebyte.popularmovies.activities.MainActivity.java

private void showLicenseDialog() {
    LayoutInflater inflater = getLayoutInflater();
    View view = inflater.inflate(R.layout.dialog_license, null);
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setPositiveButton(R.string.dismiss, new DialogInterface.OnClickListener() {
        @Override/*from   w w  w  .  j a va 2s .  c  om*/
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });
    builder.setView(view);
    TextView textView = (TextView) view.findViewById(R.id.license_text);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
        textView.setText(
                Html.fromHtml(MyFile.readFromAssets(this, "license.html"), Html.FROM_HTML_MODE_COMPACT));
    } else {
        textView.setText(Html.fromHtml(MyFile.readFromAssets(this, "license.html")));
    }
    builder.show();
}

From source file:com.r.raul.tools.MainActivity.java

private void msgTraductor() {

    AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
    LayoutInflater inflater = getLayoutInflater();
    final View dialogView = inflater.inflate(R.layout.dialog_idiomas, null);
    dialogBuilder.setView(dialogView);

    final TextView txt0 = (TextView) dialogView.findViewById(R.id.titu0);
    final TextView txt1 = (TextView) dialogView.findViewById(R.id.titu1);
    final TextView txt2 = (TextView) dialogView.findViewById(R.id.titu2);

    String urlM = "<a href=" + getString(R.string.url1_idiomas) + ">" + getString(R.string.p2_idiomas) + "</a>";
    String urlD = "<a href='" + getString(R.string.url2_idiomas) + "'>" + getString(R.string.p3_idiomas)
            + "</a>";

    dialogBuilder.setTitle(R.string.titu_idiomas); //Idiomas Languages
    txt0.setText(R.string.p1_idiomas);//w  ww .  j  a va  2 s . co m
    txt1.setMovementMethod(LinkMovementMethod.getInstance());
    txt2.setMovementMethod(LinkMovementMethod.getInstance());
    txt1.setText(Html.fromHtml(urlM));
    txt2.setText(Html.fromHtml(urlD));

    dialogBuilder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
        }
    });
    AlertDialog b = dialogBuilder.create();
    b.show();
}