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.wellsandwhistles.android.redditsp.common.DialogUtils.java

public static void showSearchDialog(Context context, int titleRes, final OnSearchListener listener) {
    final AlertDialog.Builder alertBuilder = new AlertDialog.Builder(context);
    final EditText editText = (EditText) LayoutInflater.from(context).inflate(R.layout.dialog_editbox, null);

    alertBuilder.setView(editText);// w w  w . ja va  2 s .  c o m
    alertBuilder.setTitle(titleRes);

    alertBuilder.setPositiveButton(R.string.action_search, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            final String query = General.asciiLowercase(editText.getText().toString()).trim();
            if (StringUtils.isEmpty(query)) {
                listener.onSearch(null);
            } else {
                listener.onSearch(query);
            }
        }
    });

    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.gplvote.signdoc.MainActivity.java

public static void error(String text, final Activity activity, final boolean parent_exit) {
    AlertDialog.Builder builder = new AlertDialog.Builder(activity);
    builder.setTitle(R.string.title_error).setIcon(R.drawable.cancel_icon).setMessage(text).setCancelable(false)
            .setNegativeButton(R.string.btn_ok, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();//w  w  w. j ava  2s  . c o  m
                    if (parent_exit) {
                        activity.finish();
                    }
                }
            });
    AlertDialog alert = builder.create();
    alert.show();
}

From source file:com.doplgangr.secrecy.Util.java

public static void alert(final Context context, final String title, final String message,
        final DialogInterface.OnClickListener positive, final DialogInterface.OnClickListener negative) {
    new Handler(Looper.getMainLooper()).post(new Runnable() {

        @Override//  ww  w  . j a va2  s.  co m
        public void run() {
            AlertDialog.Builder a = new AlertDialog.Builder(context);
            if (title != null)
                a.setTitle(title);
            if (message != null)
                a.setMessage(message);
            if (positive != null)
                a.setPositiveButton(context.getString(R.string.OK), positive);
            if (negative != null)
                a.setNegativeButton(context.getString(R.string.CANCEL), negative);
            a.setCancelable(false);
            a.show();
        }

    });
}

From source file:org.gplvote.signdoc.MainActivity.java

public static void alert(String text, final Activity activity, final boolean parent_exit) {
    final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
    builder.setTitle(R.string.title_warning).setIcon(R.drawable.notification_icon).setMessage(text)
            .setCancelable(false).setNegativeButton(R.string.btn_ok, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();/* w  w  w. j a va  2s. c om*/
                    if (parent_exit) {
                        activity.finish();
                    }
                }
            });
    AlertDialog alert = builder.create();
    alert.show();
}

From source file:com.otaupdater.utils.UserUtils.java

public static void showLoginDialog(final Context ctx, String defUsername, final DialogCallback dlgCallback,
        final LoginCallback loginCallback) {
    @SuppressLint("InflateParams")
    View view = LayoutInflater.from(ctx).inflate(R.layout.login_dialog, null);
    if (view == null)
        return;/*from   w  w w  .  j  av a  2  s. c om*/
    final EditText inputUsername = (EditText) view.findViewById(R.id.auth_username);
    final EditText inputPassword = (EditText) view.findViewById(R.id.auth_password);

    if (defUsername != null)
        inputUsername.setText(defUsername);

    AlertDialog.Builder builder = new AlertDialog.Builder(ctx);
    builder.setTitle(R.string.alert_login_title);
    builder.setView(view);
    builder.setPositiveButton(R.string.login, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            /* set below */ }
    });
    builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
            if (loginCallback != null)
                loginCallback.onCancel();
        }
    });

    final AlertDialog dlg = builder.create();
    dlg.setOnShowListener(new DialogInterface.OnShowListener() {
        @Override
        public void onShow(DialogInterface dialog) {
            if (dlgCallback != null)
                dlgCallback.onDialogShown(dlg);
            Button button = dlg.getButton(DialogInterface.BUTTON_POSITIVE);
            if (button == null)
                return;
            button.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    final String username = inputUsername.getText().toString();
                    final String password = inputPassword.getText().toString();

                    if (username.length() == 0 || password.length() == 0) {
                        Toast.makeText(ctx, R.string.toast_blank_userpass_error, Toast.LENGTH_LONG).show();
                        return;
                    }

                    dlg.dismiss();

                    APIUtils.userLogin(ctx, username, password, new APIUtils.ProgressDialogAPICallback(ctx,
                            ctx.getString(R.string.alert_logging_in), dlgCallback) {
                        @Override
                        public void onSuccess(String message, JSONObject respObj) {
                            try {
                                String realUsername = respObj.getString("username");
                                String hmacKey = respObj.getString("key");
                                Config.getInstance(ctx).storeLogin(realUsername, hmacKey);
                                if (loginCallback != null)
                                    loginCallback.onLoggedIn(realUsername);
                            } catch (JSONException e) {
                                e.printStackTrace();
                            }
                        }

                        @Override
                        public void onError(String message, JSONObject respObj) {
                            //TODO show some error
                        }
                    });
                }
            });
        }
    });
    dlg.setOnDismissListener(new DialogInterface.OnDismissListener() {
        @Override
        public void onDismiss(DialogInterface dialog) {
            if (dlgCallback != null)
                dlgCallback.onDialogClosed(dlg);
        }
    });
    dlg.show();
}

From source file:br.ufg.inf.es.fs.contpatri.mobile.webservice.Autenticar.java

/**
 * Mtodo que exibe um <code>Dialog</code> caso haja erro no login do
 * usurio no aplicativo.// w ww .j  a  v  a  2 s .co  m
 * 
 * @param contexto
 *            <code>Context</code> necessrio para criar e exibir a caixa de
 *            dilogo.
 * @param mensagem
 *            mensagem de erro que ser exibida na <code>Dialog</code> para
 *            informar o motivo de a aplicao no realizar o login
 *            corretamente
 */
public static void mostrarDialogo(final Context contexto, final String mensagem) {

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

    builder.setTitle("Erro");
    builder.setMessage(mensagem);
    builder.setIcon(android.R.drawable.ic_dialog_alert);

    builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(final DialogInterface dialog, final int which) {
            dialog.dismiss();
        }
    });

    final AlertDialog dialog = builder.create();
    dialog.setCanceledOnTouchOutside(true);
    dialog.show();

}

From source file:com.doplgangr.secrecy.utils.Util.java

public static void alert(final Context context, final String title, final String message,
        final DialogInterface.OnClickListener ok) {
    new Handler(Looper.getMainLooper()).post(new Runnable() {

        @Override//from w  w  w  . j  ava2 s . c  o m
        public void run() {
            AlertDialog.Builder a = new AlertDialog.Builder(context);
            if (title != null)
                a.setTitle(title);
            if (message != null)
                a.setMessage(message);
            if (ok != null)
                a.setPositiveButton("OK", ok);
            a.setCancelable(false);
            a.show();
        }

    });
}

From source file:com.doplgangr.secrecy.utils.Util.java

public static void alert(final Context context, final String title, final String message,
        final DialogInterface.OnClickListener positive, final DialogInterface.OnClickListener negative) {
    new Handler(Looper.getMainLooper()).post(new Runnable() {

        @Override/*from  w  ww .  ja v a 2s.  com*/
        public void run() {
            AlertDialog.Builder a = new AlertDialog.Builder(context);
            if (title != null)
                a.setTitle(title);
            if (message != null)
                a.setMessage(message);
            if (positive != null)
                a.setPositiveButton("OK", positive);
            if (negative != null)
                a.setNegativeButton("CANCEL", negative);
            a.setCancelable(false);
            a.show();
        }

    });
}

From source file:com.jamesgiang.aussnowcam.Utils.java

public static void About(Context c) {
    AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(c);
    dialogBuilder.setTitle(R.string.app_name);
    dialogBuilder.setIcon(R.drawable.icon);
    TextView textView = new TextView(c);
    SpannableString s = new SpannableString(c.getString(R.string.about_info));
    Linkify.addLinks(s, Linkify.WEB_URLS);
    textView.setText(s);/*from w w  w .  j a va  2  s  . c  o m*/
    textView.setGravity(Gravity.CENTER);
    textView.setMovementMethod(LinkMovementMethod.getInstance());
    dialogBuilder.setView(textView);
    dialogBuilder.show();
}

From source file:au.id.micolous.frogjump.Util.java

private static void newVersionAlert(final Activity activity) {
    // We have a new version available.  Prompt.
    AlertDialog.Builder updateDialog = new AlertDialog.Builder(activity);
    updateDialog.setTitle(R.string.update_available_title);
    updateDialog.setMessage(R.string.update_available_message);
    updateDialog.setPositiveButton(R.string.update_positive, new DialogInterface.OnClickListener() {
        @Override/*  w  ww.  j  a  v a 2  s  .  co  m*/
        public void onClick(DialogInterface dialogInterface, int i) {
            try {
                activity.startActivity(
                        new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + getPackageName())));
            } catch (ActivityNotFoundException anfe) {
                // Hmm, market is not installed
                Log.w(TAG, "Google Play is not installed; cannot install update");
            }
        }
    });
    updateDialog.setNegativeButton(R.string.update_negative, null);
    updateDialog.setCancelable(true);
    updateDialog.show();

}