Example usage for android.app AlertDialog.Builder create

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

Introduction

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

Prototype

public void create() 

Source Link

Document

Forces immediate creation of the dialog.

Usage

From source file:geert.stef.sm.beheerautokm.AddRitActivity.java

public void showNotValidNumberDialog() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle("Not a valid number").setMessage("Something like \"12.34\"")
            .setIcon(android.R.drawable.ic_dialog_alert)
            .setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    //do some thing here which you need
                }//from w w w  . j  a  va2 s. c om
            });
    AlertDialog alert = builder.create();
    alert.show();
}

From source file:com.linkbubble.util.YouTubeEmbedHelper.java

AlertDialog getEmbedResultsDialog() {
    if (mEmbedInfo.size() > 0) {
        ListView listView = new ListView(mContext);
        listView.setAdapter(new EmbedItemAdapter());

        AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
        builder.setView(listView);/*  ww  w  .  j a v a2s. c o  m*/
        builder.setIcon(mYouTubeResolveInfo.loadIcon(mContext.getPackageManager()));
        builder.setTitle(R.string.title_youtube_embed_to_load);

        final AlertDialog alertDialog = builder.create();
        alertDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);

        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                EmbedInfo embedInfo = (EmbedInfo) view.getTag();
                if (embedInfo != null) {
                    loadYouTubeVideo(embedInfo.mId);
                }
                alertDialog.dismiss();
            }
        });

        return alertDialog;
    } else {
        final AlertDialog alertDialog = new AlertDialog.Builder(mContext).create();
        alertDialog.setTitle(R.string.youtube_embed_error_title);
        alertDialog.setMessage(mContext.getString(R.string.youtube_embed_error_summary));
        alertDialog.setButton(AlertDialog.BUTTON_POSITIVE,
                mContext.getResources().getString(R.string.action_ok), new DialogInterface.OnClickListener() {

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

                });
        alertDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
        return alertDialog;
    }
}

From source file:com.androidquery.auth.GoogleHandle.java

private void accountDialog() {

    AlertDialog.Builder builder = new AlertDialog.Builder(act);
    //builder.setTitle("Select a Google account");
    accs = am.getAccountsByType("com.google");
    int size = accs.length;

    if (size == 1) {
        auth(accs[0]);//from  www  . jav  a  2 s .  co  m
    } else {

        String[] names = new String[size];
        for (int i = 0; i < size; i++) {
            names[i] = accs[i].name;
        }
        builder.setItems(names, this);
        builder.setOnCancelListener(this);

        AlertDialog dialog = builder.create();//.show();
        new AQuery(act).show(dialog);
    }
}

From source file:com.google.cast.samples.games.codelab.DrawingFragment.java

private void showDialog(String title, String message, DialogInterface.OnClickListener onClickListener) {
    if (getView() != null) {
        AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getView().getContext()).setTitle(title)
                .setMessage(message).setCancelable(false)
                .setPositiveButton(getString(R.string.game_dialog_ok_button_text), onClickListener);

        mAlertDialog = alertDialogBuilder.create();
        mAlertDialog.show();/* w w w .jav a2s.com*/
    }
}

From source file:com.jaguarlandrover.auto.remote.vehicleentry.LockActivity.java

private void handleExtra(Intent intent) {
    Bundle extras = intent.getExtras();//from ww  w . j ava 2  s  .c  o  m
    if (extras != null && extras.size() > 0) {
        for (String k : extras.keySet()) {
            Log.i(TAG, "k = " + k + " : " + extras.getString(k));
        }
    }
    if (extras != null && "dialog".equals(extras.get("_extra1"))) {
        AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
        alertDialogBuilder.setTitle("" + extras.get("_extra2"));
        alertDialogBuilder.setMessage("" + extras.get("_extra3")).setCancelable(false).setPositiveButton("OK",
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        dialog.cancel();
                    }
                });
        alertDialogBuilder.create().show();
    }
}

From source file:de.awisus.refugeeaidleipzig.views.login.FragmentAnmelden.java

/**
 * Called when this dialogue is created; Android-specific
 * Inflates the layout, initialises text field and spinner, initialises the spinner adapter to
 * show up accommodations and sets the dialogue buttons
 *
 * @param savedInstanceState Bundle of saved instance state
 * @return dialogue created by the AlertDialog.Builder
 */// w  w w  .  j  av  a 2 s.  c  o  m
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Button btAnmelden, btNeu;
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    View view = getActivity().getLayoutInflater().inflate(R.layout.fragment_anmelden, null);

    warnungID = R.string.warnung_anmelden;

    etName = (EditText) view.findViewById(R.id.etName);
    etPasswort = (EditText) view.findViewById(R.id.etPassword);
    btAnmelden = (Button) view.findViewById(R.id.btAnmelden);
    btNeu = (Button) view.findViewById(R.id.btNeu);

    btAnmelden.setOnClickListener(this);
    btNeu.setOnClickListener(this);

    builder.setView(view);

    Dialog dialog = builder.create();
    dialog.setTitle(R.string.titel_login);
    dialog.setCancelable(false);
    dialog.setCanceledOnTouchOutside(false);

    return dialog;
}

From source file:com.metaphyze.hackernewsfrontpage.HackerNewsFrontPageActivity.java

private void showError(String title, String error) {
    AlertDialog.Builder builder = new AlertDialog.Builder(HackerNewsFrontPageActivity.this);

    builder.setTitle(title);//from   ww  w. jav  a  2s.c  o m
    builder.setMessage(error);
    builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {

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

        }
    });

    builder.create().show();
}

From source file:com.jaguarlandrover.auto.remote.vehicleentry.LockActivity.java

public void keyUpdate(final UserCredentials userCredentials) {
    AlertDialog.Builder builder = new AlertDialog.Builder(LockActivity.this);
    builder.setInverseBackgroundForced(true);
    builder.setMessage("Key updates have been made").setCancelable(false).setPositiveButton("OK",
            new DialogInterface.OnClickListener() {
                @Override/*from   w w  w. j  a  v a2  s . c o  m*/
                public void onClick(DialogInterface dialog, int which) {
                    lock_fragment.setButtons(userCredentials);
                }
            });
    AlertDialog alert = builder.create();
    alert.show();
}

From source file:org.quizpoll.net.HttpHelper.java

/**
 * Shows dialog for forced update// w ww  .  ja va 2 s.c om
 */
private void showUpgradeRequiredDialog() {
    AlertDialog.Builder alert = new AlertDialog.Builder(activity);
    alert.setTitle(R.string.update_required);
    alert.setMessage(R.string.update_required_description);
    alert.setPositiveButton(R.string.go_to_market, new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(AboutActivity.MARKET_LISTING));
            activity.startActivity(intent);
        }
    });
    Dialog dialog = alert.create();
    dialog.setOwnerActivity(activity);
    dialog.show();
}

From source file:org.deviceconnect.android.uiapp.DConnectActivity.java

@Override
protected void onResumeFragments() {
    super.onResumeFragments();

    // ?????????// www. ja  va  2s  .  c  o m
    if (mError != null) {
        clearFragmentList();
        mLoadingFragment = new DialogFragment() {
            @Override
            public Dialog onCreateDialog(final Bundle savedInstanceState) {
                final AlertDialog.Builder builder = new AlertDialog.Builder(DConnectActivity.this);
                builder.setTitle(R.string.activity_failed_to_get_accesstoken);
                builder.setMessage(mError.toString());
                builder.setCancelable(true);
                mError = null;
                return builder.create();
            }
        };
        mLoadingFragment.show(getSupportFragmentManager(), "test");
    }
}