Example usage for android.app AlertDialog.Builder setTitle

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

Introduction

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

Prototype

@Override
    public void setTitle(CharSequence title) 

Source Link

Usage

From source file:edu.usf.cutr.opentripplanner.android.tasks.ServerChecker.java

@Override
protected void onPostExecute(String result) {
    if (activity.get() != null) {
        try {//from w  w w .j  ava 2  s.  co  m
            if (progressDialog != null && progressDialog.isShowing()) {
                progressDialog.dismiss();
            }
        } catch (Exception e) {
            Log.e(TAG, "Error in Server Checker PostExecute dismissing dialog: " + e);
        }
    }

    if (showMessage) {
        if (activity.get() != null) {
            AlertDialog.Builder dialog = new AlertDialog.Builder(activity.get());
            dialog.setTitle(context.getResources().getString(R.string.server_checker_info_dialog_title));
            dialog.setMessage(result);
            dialog.setNeutralButton(context.getResources().getString(android.R.string.ok), null);
            dialog.create().show();
        }
    } else {
        if (isWorking) {
            Toast.makeText(context, context.getResources().getString(R.string.server_checker_successful),
                    Toast.LENGTH_SHORT).show();
        } else {
            Toast.makeText(context, context.getResources().getString(R.string.custom_server_error),
                    Toast.LENGTH_SHORT).show();
        }
    }

    if (callback != null) {
        callback.onServerCheckerComplete(result, isWorking);
    }
}

From source file:de.grobox.blitzmail.NotificationHandlerActivity.java

@Override
protected void onNewIntent(Intent intent) {
    Bundle extras = intent.getExtras();// w  ww. j a  v a  2 s  .co m

    // show dialog for server errors
    if (extras != null && extras.getString("ContentTitle").equals(getString(R.string.error))) {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);

        builder.setTitle(getString(R.string.app_name) + " - " + getString(R.string.error));
        builder.setMessage(extras.getString("ContentText"));
        builder.setIcon(android.R.drawable.ic_dialog_alert);

        // Add the buttons
        builder.setNegativeButton(getResources().getString(R.string.dismiss),
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        deleteMail();
                        // User clicked Cancel button, close this Activity
                        finish();
                    }
                });
        builder.setNeutralButton(getResources().getString(R.string.send_later),
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        // User clicked Cancel button
                        if (BuildConfig.PRO) {
                            // close this Activity
                            finish();
                        } else {
                            AlertDialog.Builder builder = new AlertDialog.Builder(context);

                            builder.setTitle(getString(R.string.app_name));
                            builder.setMessage(getString(R.string.error_lite_version));
                            builder.setIcon(android.R.drawable.ic_dialog_info);

                            // Add the buttons
                            builder.setPositiveButton(android.R.string.ok,
                                    new DialogInterface.OnClickListener() {
                                        public void onClick(DialogInterface lite_dialog, int id) {
                                            Uri uri = Uri.parse(
                                                    "https://play.google.com/store/apps/details?id=de.grobox.blitzmail.pro");
                                            Intent intent = new Intent(Intent.ACTION_VIEW, uri);
                                            if (intent.resolveActivity(getPackageManager()) != null) {
                                                startActivity(intent);
                                            }
                                            lite_dialog.dismiss();
                                            finish();
                                        }
                                    });
                            builder.setNegativeButton(android.R.string.cancel,
                                    new DialogInterface.OnClickListener() {
                                        public void onClick(DialogInterface lite_dialog, int id) {
                                            lite_dialog.dismiss();
                                            finish();
                                        }
                                    });

                            // Create and show the AlertDialog
                            AlertDialog lite_dialog = builder.create();
                            lite_dialog.setCanceledOnTouchOutside(false);
                            lite_dialog.show();
                        }
                    }
                });
        builder.setPositiveButton(getResources().getString(R.string.try_again),
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        // Prepare start of new activity
                        Intent intent = new Intent(context, SendActivity.class);
                        intent.setAction("BlitzMailReSend");
                        intent.putExtra("mail", mMail.toString());
                        finish();

                        startActivity(intent);
                    }
                });

        // Create and show the AlertDialog
        AlertDialog dialog = builder.create();
        dialog.setCanceledOnTouchOutside(false);
        dialog.show();
    } else {
        // close activity
        finish();
    }
}

From source file:com.flurry.samples.tumblrsharing.PhotoDetailActivity.java

void displayAlert(String title, String msg) {
    AlertDialog.Builder alertBox = new AlertDialog.Builder(PhotoDetailActivity.this);
    alertBox.setTitle(title).setMessage(msg).setNeutralButton("OK", new DialogInterface.OnClickListener() {

        @Override//from  w  ww .jav a  2  s  .  co  m
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
        }
    }).setCancelable(true).show();
}

From source file:de.trier.infsec.koch.droidsheep.activities.HijackActivity.java

private void selectURL() {
    AlertDialog.Builder alert = new AlertDialog.Builder(this);

    alert.setTitle(getString(R.string.changeurl));
    alert.setMessage(getString(R.string.customurl));

    // Set an EditText view to get user input   
    final EditText inputName = new EditText(this);
    inputName.setText(HijackActivity.this.webview.getUrl());
    alert.setView(inputName);//w w  w  .  ja  v  a2s .  c  o  m

    alert.setPositiveButton("Go", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            HijackActivity.this.webview.loadUrl(inputName.getText().toString());
        }
    });

    alert.show();
}

From source file:org.starfishrespect.myconsumption.android.ui.CreateAccountActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_create_account);

    editTextUsername = (EditText) findViewById(R.id.editTextUsername);
    editTextPassword = (EditText) findViewById(R.id.editTextPassword);
    editTextPassword2 = (EditText) findViewById(R.id.editTextPassword2);
    buttonCreateAccount = (Button) findViewById(R.id.buttonCreateAccount);
    buttonCreateAccount.setOnClickListener(new View.OnClickListener() {
        @Override//  ww  w  .j av a2 s. co  m
        public void onClick(View v) {
            if (!MiscFunctions.isOnline(CreateAccountActivity.this)) {
                MiscFunctions.makeOfflineDialog(CreateAccountActivity.this).show();
                return;
            }
            if (editTextUsername.getText().toString().equals("")
                    || editTextPassword.getText().toString().equals("")
                    || editTextPassword2.getText().toString().equals("")) {
                Toast.makeText(CreateAccountActivity.this,
                        getString(R.string.dialog_message_error_must_fill_all_fields), Toast.LENGTH_LONG)
                        .show();
                return;
            }

            if (!editTextPassword.getText().toString().equals(editTextPassword2.getText().toString())) {
                Toast.makeText(CreateAccountActivity.this, R.string.dialog_message_error_password_must_match,
                        Toast.LENGTH_LONG).show();
                return;
            }

            new AsyncTask<Void, Void, Integer>() {

                @Override
                protected Integer doInBackground(Void... params) {
                    return createAccount();
                }

                @Override
                protected void onPostExecute(Integer result) {
                    if (result == 0) {
                        setResult(RESULT_OK);
                        finish();
                    } else {
                        AlertDialog.Builder builder = new AlertDialog.Builder(CreateAccountActivity.this);
                        builder.setTitle(R.string.dialog_title_error);
                        builder.setPositiveButton(R.string.button_ok, new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                dialog.dismiss();
                            }
                        });
                        switch (result) {
                        case SimpleResponseDTO.STATUS_ALREADY_EXISTS:
                            builder.setMessage(R.string.dialog_message_error_user_already_exists);
                            break;
                        default:
                            builder.setMessage("An error has occurred. You might want to "
                                    + "check your internet connection or contact the application provider.");
                            break;

                        }
                        builder.show();
                    }
                }
            }.execute();
        }
    });
}

From source file:com.googlecode.android_scripting.facade.ui.SeekBarDialogTask.java

@Override
public void onCreate() {
    super.onCreate();
    mSeekBar = new SeekBar(getActivity());
    mSeekBar.setMax(mMax);//from w ww .  ja v a2  s .co  m
    mSeekBar.setProgress(mProgress);
    mSeekBar.setPadding(10, 0, 10, 3);
    mSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

        public void onStopTrackingTouch(SeekBar arg0) {
        }

        public void onStartTrackingTouch(SeekBar arg0) {
        }

        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            EventFacade eventFacade = getEventFacade();
            if (eventFacade != null) {
                JSONObject result = new JSONObject();
                try {
                    result.put("which", "seekbar");
                    result.put("progress", mSeekBar.getProgress());
                    result.put("fromuser", fromUser);
                    eventFacade.postEvent("dialog", result);
                } catch (JSONException e) {
                    Log.e(e);
                }
            }
        }
    });

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    if (mTitle != null) {
        builder.setTitle(mTitle);
    }
    if (mMessage != null) {
        builder.setMessage(mMessage);
    }
    builder.setView(mSeekBar);
    configureButtons(builder, getActivity());
    addOnCancelListener(builder, getActivity());
    mDialog = builder.show();
    mShowLatch.countDown();
}

From source file:com.yozio.demo.implementations.share.ShareButtonsActivity.java

public void showShareCommentDialog(Context context, final DialogFlowController controller) {

    final EditText text = new EditText(context);
    text.setMinLines(5);//from   w  w  w.  j  a  va 2 s  . c  o  m
    text.setGravity(Gravity.TOP);

    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setTitle("Share");
    builder.setMessage("Enter a comment (Optional)");
    builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            controller.onContinue(text.getText().toString());
        }
    });
    builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            controller.onCancel();
        }
    });

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

From source file:co.dilaver.quoter.fragments.PopularFragment.java

@Override
public void pqInfoClicked() {
    android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(getActivity());
    builder.setTitle(getString(R.string.str_Info));
    builder.setMessage(Html.fromHtml(getString(R.string.str_TakenFromReddit)));
    builder.setCancelable(true);/*from   ww  w.java  2  s . c  o  m*/
    builder.show();
}

From source file:de.gadc.moneybeam.MoneyBeamActivity.java

/**
 * This method presents the user the dialog that enables him to enter his
 * email address./*from w w w.  j  a  v  a2s  . c o  m*/
 */
private void showEmailDialog() {
    final EditText editText = new EditText(this);
    AlertDialog.Builder emailDialogBuilder = new Builder(this);
    emailDialogBuilder.setTitle(R.string.hint_email);
    editText.setImeOptions(EditorInfo.IME_ACTION_DONE);
    editText.setInputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
    emailDialogBuilder.setView(editText);
    emailDialogBuilder.setPositiveButton(R.string.button_ok, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            String mail = editText.getText().toString();
            prefs.edit().putString(Configuration.PREF_MAIL, mail).commit();
        }
    });
    emailDialogBuilder.setNegativeButton(R.string.button_cancel, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });
    emailDialogBuilder.show();
}