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:com.poinsart.votar.VotarMain.java

@Override
public void onBackPressed() {
    AlertDialog.Builder alert = new AlertDialog.Builder(this);

    alert.setTitle(getString(R.string.quit_title));
    alert.setMessage(getString(R.string.quit_message));

    alert.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            finish();/*ww  w . ja  v  a2  s  .  c  o m*/
        }
    });

    alert.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            //
        }
    });

    alert.show();
}

From source file:dtu.ds.warnme.app.dialog.LoginDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    View view = getActivity().getLayoutInflater().inflate(R.layout.dialog_login, null);
    builder.setView(view);/*  www. ja v a2  s . c o m*/
    builder.setTitle(R.string.login);
    builder.setPositiveButton(R.string.login, new DialogInterface.OnClickListener() {

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

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

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

    progressView = view.findViewById(R.id.dialog_login_progress);
    formView = view.findViewById(R.id.dialog_login_form);

    usernameEditText = (EditText) view.findViewById(R.id.dialog_login_edit_text_username);
    usernameEditText.addTextChangedListener(new TextWatcher() {

        @Override
        public void afterTextChanged(Editable s) {
            // Nothing to do here...
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            // Nothing to do here...
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            usernameEditText.setError(null);
        }
    });

    passwordEditText = (EditText) view.findViewById(R.id.dialog_login_edit_text_password);
    passwordEditText.addTextChangedListener(new TextWatcher() {

        @Override
        public void afterTextChanged(Editable s) {
            // Nothing to do here...
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            // Nothing to do here...
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            passwordEditText.setError(null);
        }
    });

    dialog = builder.create();

    dialog.setOnShowListener(new DialogInterface.OnShowListener() {

        @Override
        public void onShow(DialogInterface dialogInterface) {

            final Button positiveButton = dialog.getButton(DialogInterface.BUTTON_POSITIVE);
            positiveButton.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    final String username = usernameEditText.getText().toString();
                    String password = passwordEditText.getText().toString();

                    boolean formOk = true;

                    if (StringUtils.isBlank(username)) {
                        usernameEditText.setError(getString(R.string.cannot_be_empty));
                        formOk = false;
                    }
                    if (StringUtils.isBlank(password)) {
                        passwordEditText.setError(getString(R.string.cannot_be_empty));
                        formOk = false;
                    }

                    if (!formOk) {
                        Log.d(TAG, "Form contains errors.");
                        return;
                    }

                    final String hashedPassword = SecurityUtils.hashSHA512Base64(password);

                    tempRestClient = new RestClient(Prefs.getHost(), Prefs.getPort(), Prefs.getWsContextPath(),
                            username, hashedPassword, Prefs.getRealm());
                    tempRestClient.getProfile(dialog.getContext(),
                            new GsonHttpResponseHandler<User>(new TypeToken<User>() {
                            }.getType()) {

                                @Override
                                public void onFailure(int statusCode, Header[] headers, String responseBody,
                                        Throwable error) {
                                    Log.e(TAG, "Login failed. [statusCode = " + statusCode + ", error=" + error
                                            + "]");

                                    if (statusCode == 0) {
                                        Toast.makeText(dialog.getOwnerActivity(), R.string.check_connection,
                                                Toast.LENGTH_LONG).show();
                                        return;
                                    }

                                    usernameEditText.setError(
                                            getResources().getText(R.string.bad_username_or_password));
                                    passwordEditText.setError(
                                            getResources().getText(R.string.bad_username_or_password));
                                    listener.onLoginFailure();
                                }

                                @Override
                                public void onFinish() {
                                    positiveButton.setEnabled(true);
                                    UiUtilities.fadeInFadeOut(formView, progressView);
                                }

                                @Override
                                public void onStart() {
                                    positiveButton.setEnabled(false);
                                    UiUtilities.fadeInFadeOut(progressView, formView);
                                }

                                @Override
                                public void onSuccess(int statusCode, Header[] headers, User user) {
                                    Log.i(TAG, "Login succeeded. [statusCode = " + statusCode + "]");
                                    UserProfileHolder.setUserProfile(user);
                                    Prefs.setUsername(username);
                                    Prefs.setPasswordHash(hashedPassword);
                                    dialog.dismiss();

                                    listener.onLoginSuccess();
                                }

                            });

                }
            });

            final Button negativeButton = dialog.getButton(DialogInterface.BUTTON_NEGATIVE);
            negativeButton.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    if (tempRestClient != null) {
                        tempRestClient.cancelRequests(dialog.getOwnerActivity(), true);
                    }
                    dialog.dismiss();
                }
            });
        }
    });

    return dialog;
}

From source file:com.mobicage.rogerthat.plugins.scan.ProcessScanActivity.java

private void showError(Intent intent) {
    final String errorMessage = intent.getStringExtra(ERROR_MESSAGE);
    if (TextUtils.isEmptyOrWhitespace(errorMessage)) {
        finish();//from w ww . j a v a 2 s . co  m
        showErrorToast();
    } else {
        final String errorCaption = intent.getStringExtra(ERROR_CAPTION);
        final String errorAction = intent.getStringExtra(ERROR_ACTION);
        final String errorTitle = intent.getStringExtra(ERROR_TITLE);

        final AlertDialog.Builder builder = new AlertDialog.Builder(ProcessScanActivity.this);
        builder.setTitle(errorTitle);
        builder.setMessage(errorMessage);
        builder.setNegativeButton(R.string.rogerthat, new AlertDialog.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                finish();
            }
        });

        if (!TextUtils.isEmptyOrWhitespace(errorCaption) && !TextUtils.isEmptyOrWhitespace(errorAction)) {
            builder.setPositiveButton(errorCaption, new AlertDialog.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(errorAction));
                    startActivity(intent);
                    dialog.dismiss();
                    finish();
                }
            });
        }

        builder.show();
    }
}

From source file:fi.mikuz.boarder.gui.internet.InternetMenu.java

@Override
public void onConnectionSuccessful(ConnectionSuccessfulResponse connectionSuccessfulResponse)
        throws JSONException {
    ConnectionUtils.connectionSuccessful(InternetMenu.this, connectionSuccessfulResponse);

    if (ConnectionUtils.checkConnectionId(connectionSuccessfulResponse, InternetMenu.mGetServiceVersionURL)) {
        mDatabaseVersionChecked = true;/* w w  w. jav  a2  s .co  m*/

        int serviceVersion = connectionSuccessfulResponse.getJSONObject().getInt(ConnectionUtils.returnData);
        if (serviceVersion == -1) {
            AlertDialog.Builder builder = new AlertDialog.Builder(InternetMenu.this);
            builder.setTitle("Maintenance");
            builder.setMessage("Boarder web service is under maintenance. Please try again later.");
            builder.setCancelable(false);
            builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    InternetMenu.this.finish();
                }
            });

            builder.show();
        } else if (mServiceVersion < serviceVersion) {
            AlertDialog.Builder builder = new AlertDialog.Builder(InternetMenu.this);
            builder.setTitle("Old version");
            builder.setMessage(
                    "You have an old version of Boarder. Your version is not compatible with Boarder web service.\n\n"
                            + "Please update.");
            builder.setCancelable(false);

            builder.setPositiveButton("Update", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    ExternalIntent.openGooglePlay(InternetMenu.this);
                    InternetMenu.this.finish();
                }
            });

            builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    InternetMenu.this.finish();
                }
            });

            builder.show();
        }
    } else if (ConnectionUtils.checkConnectionId(connectionSuccessfulResponse,
            InternetMenu.mGetSessionValidURL)) {
        mSessionValidityChecked = true;
        if (connectionSuccessfulResponse.getJSONObject().getInt(InternetMenu.SESSION_VALID_KEY) == 0) {
            startLogin();
        } else {
            String accountMessage = connectionSuccessfulResponse.getJSONObject()
                    .getString(InternetMenu.ACCOUNT_MESSAGE_KEY);
            updateAccountMessage(accountMessage);
        }
    }

    afterConnection();
}

From source file:com.lovejoy777sarootool.rootool.dialogs.FilePropertiesDialog.java

@Override
public Dialog onCreateDialog(Bundle state) {
    activity = getActivity();// w  w w. ja  v  a2 s  .  c om
    final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
    mAdapter = new PropertiesAdapter(activity, mFile);
    builder.setTitle(mFile.getName());
    builder.setNeutralButton(R.string.cancel, null);
    builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            final FilePermissionsPagerItem fragment = (FilePermissionsPagerItem) mAdapter.getItem(1);
            fragment.applyPermissions(activity);
        }
    });
    final View content = activity.getLayoutInflater().inflate(R.layout.dialog_properties_container, null);
    this.initView(content);
    builder.setView(content);
    return builder.create();
}

From source file:com.parking.billing.ParkingPayment.java

private Dialog createDialog(int titleId, int messageId) {
    String helpUrl = replaceLanguageAndRegion(getString(R.string.help_url));
    if (BillingConstants.DEBUG) {
        Log.i(TAG, helpUrl);/*from w  w  w .  j  av a 2s.  c o m*/
    }
    final Uri helpUri = Uri.parse(helpUrl);

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(titleId).setIcon(android.R.drawable.stat_sys_warning).setMessage(messageId)
            .setCancelable(false).setPositiveButton(android.R.string.ok, null)
            .setNegativeButton(R.string.learn_more, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    Intent intent = new Intent(Intent.ACTION_VIEW, helpUri);
                    startActivity(intent);
                }
            });
    return builder.create();
}

From source file:com.google.zxing.client.android.CaptureActivity.java

private void displayFrameworkBugMessageAndExit() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(getString(EUExUtil.getResStringID("app_name")));
    builder.setMessage(getString(EUExUtil.getResStringID("plugin_uexscanner_msg_camera_framework_bug")));
    builder.setPositiveButton(EUExUtil.getResStringID("confirm"), new FinishListener(this));
    builder.setOnCancelListener(new FinishListener(this));
    builder.show();//  w  w w  . j  ava  2  s. co  m
}

From source file:com.openerp.addons.note.EditNoteFragment.java

public void createNotetag() {

    AlertDialog.Builder builder = new Builder(scope.context());
    final EditText tag = new EditText(scope.context());
    builder.setTitle("Tag Name").setMessage("Enter new Tag").setView(tag);

    builder.setPositiveButton("Create", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface di, int i) {
            // do something with onClick
            if (tag.getText().length() > 0) {
                LinkedHashMap<String, String> newTag = db.writeNoteTags(tag.getText().toString());
                noteTags.addObject(//from w  ww .  ja  v  a  2s  .  c o m
                        new TagsItems(Integer.parseInt(newTag.get("newID")), newTag.get("tagName"), ""));
            } else {
                Toast.makeText(scope.context(), "Enter Tag First", Toast.LENGTH_LONG).show();
            }
        }
    });

    builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface di, int i) {
        }
    });

    builder.create().show();
}

From source file:com.microsoft.o365_android_onenote_rest.SnippetDetailFragment.java

private retrofit.Callback<String[]> getSetUpCallback() {
    return new retrofit.Callback<String[]>() {
        @Override//from  w  ww  .jav  a 2 s  .c o m
        public void success(String[] strings, Response response) {
            mProgressbar.setVisibility(View.GONE);
            if (isAdded() && (null == response || strings.length > 0)) {
                mRunButton.setEnabled(true);
                if (strings.length > 0) {
                    populateSpinner(strings);
                }
            } else if (isAdded() && strings.length <= 0 && null != response) {
                AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
                builder.setTitle(R.string.err_setup).setMessage(R.string.err_setup_msg)
                        .setPositiveButton(R.string.dismiss, null).show();
            }
        }

        @Override
        public void failure(RetrofitError error) {
            if (isAdded()) {
                displayThrowable(error.getCause());
                mProgressbar.setVisibility(View.GONE);
            }
        }
    };
}

From source file:me.piebridge.prevent.ui.UserGuideActivity.java

private void showVersionInfo() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(getString(R.string.app_name) + "(" + BuildConfig.VERSION_NAME + ")");
    builder.setMessage(getVersionInfo(false));
    builder.setIcon(R.drawable.ic_launcher);
    builder.setPositiveButton(getString(android.R.string.copy), new DialogInterface.OnClickListener() {
        @Override/* w  w  w.  j  ava 2 s .c  o m*/
        public void onClick(DialogInterface dialog, int which) {
            DeprecatedUtils.setClipboard(getBaseContext(), getVersionInfo(true));
        }
    });
    builder.create().show();
}