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:Main.java

public static void displayErrorStay(String message, Context context) {
    // no deals found so display a popup and return to search options
    AlertDialog.Builder builder = new AlertDialog.Builder(context);

    // set title/*from www  .  j  av a2s . c  o m*/
    builder.setTitle("No Results");

    // set dialog message
    builder.setMessage(message).setCancelable(false).setPositiveButton("Ok",
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();
                }
            });
    // create alert dialog
    AlertDialog alertDialog = builder.create();

    // show it
    alertDialog.show();
}

From source file:Main.java

private static AlertDialog buildErrorDialog(final Activity context, String title, String description,
        String buttonText) {/* w  w  w . j  av  a2  s  .  c o  m*/

    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setTitle(title);
    builder.setMessage(description);
    builder.setCancelable(false);
    builder.setPositiveButton(buttonText, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(final DialogInterface dialog, int which) {
            new Handler().post(new Runnable() {
                @Override
                public void run() {
                    dialog.dismiss();
                    context.finish();
                }
            });
        }
    });

    return builder.create();
}

From source file:Main.java

/**
 * Show dialog and give 2 options: go to settings or leave the app
 *
 * @param activity the activity//from  w w w  . ja  v  a2  s.  c  om
 */
private static void showDialog(final Activity activity) {
    AlertDialog.Builder builder = new AlertDialog.Builder(activity);

    builder.setTitle("Bluetooth is turned off");
    builder.setMessage("The Tapcentive Application requires Bluetooth to be turned ON");
    builder.setPositiveButton("Settings", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            Intent setnfc = new Intent(Settings.ACTION_BLUETOOTH_SETTINGS);
            activity.startActivity(setnfc);
        }
    });
    builder.setNegativeButton("Close", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            dialog.cancel();
            activity.finish();
        }
    });
    builder.show();
}

From source file:Main.java

public static void getTabList(String strTitle, final ViewPager vp, Activity activity) {
    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(activity);
    alertDialogBuilder.setTitle(strTitle);

    List<String> listItems = new ArrayList<String>();
    for (byte i = 0; i < vp.getAdapter().getCount(); i++) {
        listItems.add(vp.getAdapter().getPageTitle(i).toString());
    }/*from w w w  .j a va 2s . c  om*/
    alertDialogBuilder.setItems(listItems.toArray(new CharSequence[listItems.size()]),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    vp.setCurrentItem(which);
                }
            }).show();
}

From source file:Main.java

public static AlertDialog showDownloadDialog(final Context ctx) {
    AlertDialog.Builder downloadDialog = new AlertDialog.Builder(ctx);
    downloadDialog.setTitle("Layar is not available");
    downloadDialog.setMessage("Do you want to download it from the market?");
    downloadDialog.setPositiveButton("Yes", new DialogInterface.OnClickListener() {

        @Override//from   w  w  w.j av a 2  s. com
        public void onClick(DialogInterface dialogInterface, int i) {
            Uri uri = Uri.parse("market://details?id=com.layar");
            Intent intent = new Intent(Intent.ACTION_VIEW, uri);
            try {
                ctx.startActivity(intent);
            } catch (ActivityNotFoundException anfe) {
                Toast.makeText(ctx, "Market not installed", Toast.LENGTH_SHORT).show();
            }
        }

    });

    downloadDialog.setNegativeButton("No", new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialogInterface, int i) {
        }

    });

    return downloadDialog.show();
}

From source file:Main.java

public static void showMessage(Context _context, String title, String message, int icon,
        DialogInterface.OnClickListener ackHandler) {
    AlertDialog.Builder builder = new AlertDialog.Builder(_context);
    builder.setTitle(title);
    builder.setMessage(Html.fromHtml(message));
    builder.setCancelable(false);/*  w ww.j ava2  s .  co  m*/
    builder.setPositiveButton("Acknowledged", ackHandler);
    builder.setIcon(icon);
    boolean show = true;
    if (_context instanceof Activity) {
        Activity activity = (Activity) _context;
        if (activity.isFinishing()) {
            show = false;
        }
    }
    if (show)
        builder.show();
}

From source file:Main.java

public static void displayError(String message, final Class<?> activity, final Context context) {
    // no deals found so display a popup and return to search options
    AlertDialog.Builder builder = new AlertDialog.Builder(context);

    // set title/*from  ww  w .  j a v  a  2  s .  c  o  m*/
    builder.setTitle("No Results");

    // set dialog message
    builder.setMessage(message).setCancelable(false).setPositiveButton("Ok",
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();
                    Intent i = new Intent(context, activity);
                    ((Activity) (context)).finish();
                    i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NO_HISTORY);
                    context.startActivity(i);
                }
            });
    // create alert dialog
    AlertDialog alertDialog = builder.create();

    // show it
    alertDialog.show();
}

From source file:Main.java

public static AlertDialog createErrorDialog(final Activity activity, String title, String message,
        final boolean doFinish) {
    final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
    builder.setMessage(message);//w  ww  .ja  v  a 2s . co m
    builder.setTitle(title);
    builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            if (doFinish) {
                activity.finish();
            }
        }
    });
    return builder.create();
}

From source file:Main.java

/**
 * Dialog//www.j  av a  2  s .c o m
 * @param context
 * @param iconId
 * @param title
 * @param message
 * @param positiveBtnName
 * @param negativeBtnName
 * @param positiveBtnListener
 * @param negativeBtnListener
 * @return
 */
public static Dialog createConfirmDialog(Context context, int iconId, String title, String message,
        String positiveBtnName, String negativeBtnName,
        android.content.DialogInterface.OnClickListener positiveBtnListener,
        android.content.DialogInterface.OnClickListener negativeBtnListener) {
    Dialog dialog = null;
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setIcon(iconId);
    builder.setTitle(title);
    builder.setMessage(message);
    builder.setPositiveButton(positiveBtnName, positiveBtnListener);
    builder.setNegativeButton(negativeBtnName, negativeBtnListener);
    dialog = builder.create();
    return dialog;
}

From source file:Main.java

public static void showMessage(Context context, String title, String message, OnDismissListener listener) {
    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);

    // set title/*from  ww  w. ja va 2 s.c  o  m*/
    alertDialogBuilder.setTitle(title);

    // set dialog message
    alertDialogBuilder.setMessage(message).setCancelable(true);

    // create alert dialog
    AlertDialog alertDialog = alertDialogBuilder.create();

    alertDialog.setCanceledOnTouchOutside(true);
    if (listener != null)
        alertDialog.setOnDismissListener(listener);
    // show it
    alertDialog.show();
}