Java Code Examples for android.app.AlertDialog.Builder#setTitle()

The following examples show how to use android.app.AlertDialog.Builder#setTitle() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MMAlert.java    From wechatsdk-xamarin with Apache License 2.0 6 votes vote down vote up
public static AlertDialog showAlert(final Context context, final int msgId, final int titleId, final DialogInterface.OnClickListener lOk, final DialogInterface.OnClickListener lCancel) {
	if (context instanceof Activity && ((Activity) context).isFinishing()) {
		return null;
	}

	final Builder builder = new AlertDialog.Builder(context);
	builder.setIcon(R.drawable.ic_dialog_alert);
	builder.setTitle(titleId);
	builder.setMessage(msgId);
	builder.setPositiveButton(R.string.app_ok, lOk);
	builder.setNegativeButton(R.string.app_cancel, lCancel);
	// builder.setCancelable(false);
	final AlertDialog alert = builder.create();
	alert.show();
	return alert;
}
 
Example 2
Source File: MMAlert.java    From wechatsdk-xamarin with Apache License 2.0 6 votes vote down vote up
public static AlertDialog showAlert(final Context context, final String title, final View view, final String ok, final String cancel, final DialogInterface.OnClickListener lOk,
		final DialogInterface.OnClickListener lCancel) {
	if (context instanceof Activity && ((Activity) context).isFinishing()) {
		return null;
	}

	final Builder builder = new AlertDialog.Builder(context);
	builder.setTitle(title);
	builder.setView(view);
	builder.setPositiveButton(ok, lOk);
	builder.setNegativeButton(cancel, lCancel);
	// builder.setCancelable(false);
	final AlertDialog alert = builder.create();
	alert.show();
	return alert;
}
 
Example 3
Source File: MMAlert.java    From wechatsdk-xamarin with Apache License 2.0 6 votes vote down vote up
public static AlertDialog showAlert(final Context context, final String msg, final String title, final DialogInterface.OnClickListener lOk, final DialogInterface.OnClickListener lCancel) {
	if (context instanceof Activity && ((Activity) context).isFinishing()) {
		return null;
	}

	final Builder builder = new AlertDialog.Builder(context);
	builder.setIcon(R.drawable.ic_dialog_alert);
	builder.setTitle(title);
	builder.setMessage(msg);
	builder.setPositiveButton(R.string.app_ok, lOk);
	builder.setNegativeButton(R.string.app_cancel, lCancel);
	// builder.setCancelable(false);
	final AlertDialog alert = builder.create();
	alert.show();
	return alert;
}
 
Example 4
Source File: AlertDialogFragment.java    From codeexamples-android with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
	Builder alertDialog = new AlertDialog.Builder(getActivity());
	alertDialog.setTitle("Alert!");
	alertDialog.setMessage("This is a notication dialog");
	return alertDialog.create();
}
 
Example 5
Source File: Display.java    From Women-Safety-App with GNU General Public License v2.0 5 votes vote down vote up
public void showMessage(String title,String message)
{
    Builder builder=new Builder(this);
    builder.setCancelable(true);
    builder.setTitle(title);
    builder.setMessage(message);
    builder.show();
}
 
Example 6
Source File: AlertDialogFragment.java    From codeexamples-android with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
	Builder alertDialog = new AlertDialog.Builder(getActivity());
	alertDialog.setTitle("Alert!");
	alertDialog.setMessage("This is a notication dialog");
	return alertDialog.create();
}
 
Example 7
Source File: BillModeListPreference.java    From callmeter with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onDialogClosed(final boolean positiveResult) {
    final String ov = getValue();
    super.onDialogClosed(positiveResult);
    if (positiveResult) {
        String v = getValue();
        if (v == null || !v.contains("/")) { // custom bill mode
            Builder b = new Builder(getContext());
            final EditText et = new EditText(getContext());
            et.setText(ov);
            b.setView(et);
            b.setCancelable(false);
            b.setTitle(getTitle());
            b.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(final DialogInterface paramDialogInterface,
                        final int paramInt) {
                    BillModeListPreference.this.setValue(ov);
                }
            });
            b.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(final DialogInterface dialog, final int which) {
                    String nv = et.getText().toString().trim();
                    final String[] t = nv.toString().split("/");
                    if (t.length != 2 || !TextUtils.isDigitsOnly(t[0])
                            || !TextUtils.isDigitsOnly(t[1])) {
                        Toast.makeText(BillModeListPreference.this.ctx, R.string.missing_slash,
                                Toast.LENGTH_LONG).show();
                        BillModeListPreference.this.setValue(ov);
                    } else {
                        BillModeListPreference.this.setValue(nv);
                    }
                }
            });
            b.show();
        }
    }
}
 
Example 8
Source File: Utils.java    From bankomatinfos with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Display a alert dialog
 * 
 * @param ctx
 * @param title
 * @param message
 */
public static void displaySimpleAlertDialog(Context ctx, String title,
		String message) {
	Builder builder = new AlertDialog.Builder(ctx);
	if (title != null) {
		builder.setTitle(title);
	}
	if (message != null) {
		builder.setMessage(message);
	}
	builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
		public void onClick(DialogInterface dialog, int id) {
		}
	}).create().show();
}
 
Example 9
Source File: HourGroupEdit.java    From callmeter with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onOptionsItemSelected(final MenuItem item) {
    switch (item.getItemId()) {
        case R.id.item_add:
            showHourDialog(-1);
            return true;
        case R.id.item_delete:
            Builder b = new Builder(this);
            b.setTitle(R.string.delete_group_);
            b.setMessage(R.string.delete_group_hint);
            b.setNegativeButton(android.R.string.no, null);
            b.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(final DialogInterface dialog, final int which) {
                    HourGroupEdit.this.getContentResolver().delete(
                            ContentUris.withAppendedId(DataProvider.HoursGroup.CONTENT_URI,
                                    HourGroupEdit.this.gid), null, null);
                    Preferences.setDefaultPlan(HourGroupEdit.this, false);
                    RuleMatcher.unmatch(HourGroupEdit.this);
                    HourGroupEdit.this.finish();
                }
            });
            b.show();
            return true;
        case R.id.item_rename:
            showNameDialog();
            return true;
        case R.id.item_help:
            showHelp(R.string.hourgroup_help);
            return true;
        default:
            return false;
    }
}
 
Example 10
Source File: SanaUtil.java    From sana.mobile with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static AlertDialog okCancelDialog(Context context, String title,
                                         String message, DialogInterface.OnClickListener okCancel) {
    Builder dialogBuilder = new Builder(context);
    dialogBuilder.setPositiveButton(context.getResources().getString(
            R.string.general_ok), okCancel);
    dialogBuilder.setTitle(title);
    dialogBuilder.setMessage(message);
    dialogBuilder.setNegativeButton(context.getResources().getString(
            R.string.general_cancel), okCancel);
    return dialogBuilder.create();
}
 
Example 11
Source File: MMAlert.java    From wechatsdk-xamarin with Apache License 2.0 5 votes vote down vote up
public static AlertDialog showAlert(final Context context, final String title, final View view, final DialogInterface.OnCancelListener lCancel) {
	if (context instanceof Activity && ((Activity) context).isFinishing()) {
		return null;
	}

	final Builder builder = new AlertDialog.Builder(context);
	builder.setTitle(title);
	builder.setView(view);
	// builder.setCancelable(true);
	builder.setOnCancelListener(lCancel);
	final AlertDialog alert = builder.create();
	alert.show();
	return alert;
}
 
Example 12
Source File: MMAlert.java    From wechatsdk-xamarin with Apache License 2.0 5 votes vote down vote up
public static AlertDialog showAlert(final Context context, final String title, final View view, final DialogInterface.OnClickListener lOk) {
	if (context instanceof Activity && ((Activity) context).isFinishing()) {
		return null;
	}

	final Builder builder = new AlertDialog.Builder(context);
	builder.setTitle(title);
	builder.setView(view);
	builder.setPositiveButton(R.string.app_ok, lOk);
	// builder.setCancelable(true);
	final AlertDialog alert = builder.create();
	alert.show();
	return alert;
}
 
Example 13
Source File: CVBillModePreference.java    From callmeter with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void onDialogClosed(final boolean positiveResult) {
    final String ov = getValue();
    super.onDialogClosed(positiveResult);
    if (positiveResult) {
        String v = getValue();
        if (v == null || !v.contains("/")) { // custom bill mode
            Builder b = new Builder(getContext());
            final EditText et = new EditText(getContext());
            et.setText(ov);
            b.setView(et);
            b.setCancelable(false);
            b.setTitle(getTitle());
            b.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(final DialogInterface paramDialogInterface,
                        final int paramInt) {
                    CVBillModePreference.this.setValue(ov);
                }
            });
            b.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(final DialogInterface dialog, final int which) {
                    String nv = et.getText().toString().trim();
                    final String[] t = nv.toString().split("/");
                    if (t.length != 2 || !TextUtils.isDigitsOnly(t[0])
                            || !TextUtils.isDigitsOnly(t[1])) {
                        Toast.makeText(CVBillModePreference.this.ctx, R.string.missing_slash,
                                Toast.LENGTH_LONG).show();
                        CVBillModePreference.this.setValue(ov);
                    } else {
                        CVBillModePreference.this.setValue(nv);
                        CVBillModePreference.this.cv
                                .put(CVBillModePreference.this.getKey(), nv);
                        if (CVBillModePreference.this.ul != null) {
                            CVBillModePreference.this.ul
                                    .onUpdateValue(CVBillModePreference.this);
                        }
                    }
                }
            });
            b.show();
        } else {
            cv.put(getKey(), v);
            if (ul != null) {
                ul.onUpdateValue(this);
            }
        }
    }
}
 
Example 14
Source File: ColorPickerPreference.java    From Android-Color-Picker with Apache License 2.0 4 votes vote down vote up
@Override
protected void onPrepareDialogBuilder(Builder builder) {
    super.onPrepareDialogBuilder(builder);
    builder.setTitle(null); // remove dialog title to get more space for color picker
}
 
Example 15
Source File: ConfirmAPIActivity.java    From android with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void onResume() {
    super.onResume();
    try {
        mPackage = getCallingPackage();
        if (mPackage == null) {
            finish();
            return;
        }


        PackageManager pm = getPackageManager();
        ApplicationInfo app = pm.getApplicationInfo(mPackage, 0);

        View view = View.inflate(this, R.layout.api_confirm, null);
        ((ImageView) view.findViewById(R.id.icon)).setImageDrawable(app.loadIcon(pm));
        ((TextView) view.findViewById(R.id.prompt)).setText(
                getString(R.string.prompt, app.loadLabel(pm), getString(R.string.app)));
        ((CompoundButton) view.findViewById(R.id.check)).setOnCheckedChangeListener(this);


        Builder builder = new AlertDialog.Builder(this);

        builder.setView(view);

        builder.setIconAttribute(android.R.attr.alertDialogIcon);
        builder.setTitle(android.R.string.dialog_alert_title);
        builder.setPositiveButton(android.R.string.ok, this);
        builder.setNegativeButton(android.R.string.cancel, this);

        mAlert = builder.create();
        mAlert.setCanceledOnTouchOutside(false);

        mAlert.setOnShowListener(new OnShowListener() {

            @Override
            public void onShow(DialogInterface dialog) {
                mButton = mAlert.getButton(DialogInterface.BUTTON_POSITIVE);
                mButton.setEnabled(false);

            }
        });

        //setCloseOnTouchOutside(false);

        mAlert.show();

    } catch (Exception e) {
        Log.e(TAG, "onResume", e);
        finish();
    }
}
 
Example 16
Source File: Util.java    From FacebookImageShareIntent with MIT License 3 votes vote down vote up
/**
 * Display a simple alert dialog with the given text and title.
 *
 * @param context
 *          Android context in which the dialog should be displayed
 * @param title
 *          Alert dialog title
 * @param text
 *          Alert dialog message
 */
@Deprecated
public static void showAlert(Context context, String title, String text) {
    Builder alertBuilder = new Builder(context);
    alertBuilder.setTitle(title);
    alertBuilder.setMessage(text);
    alertBuilder.create().show();
}
 
Example 17
Source File: Util.java    From FacebookNewsfeedSample-Android with Apache License 2.0 3 votes vote down vote up
/**
 * Display a simple alert dialog with the given text and title.
 *
 * @param context
 *          Android context in which the dialog should be displayed
 * @param title
 *          Alert dialog title
 * @param text
 *          Alert dialog message
 */
@Deprecated
public static void showAlert(Context context, String title, String text) {
    Builder alertBuilder = new Builder(context);
    alertBuilder.setTitle(title);
    alertBuilder.setMessage(text);
    alertBuilder.create().show();
}
 
Example 18
Source File: Util.java    From android-skeleton-project with MIT License 3 votes vote down vote up
/**
 * Display a simple alert dialog with the given text and title.
 *
 * @param context
 *          Android context in which the dialog should be displayed
 * @param title
 *          Alert dialog title
 * @param text
 *          Alert dialog message
 */
@Deprecated
public static void showAlert(Context context, String title, String text) {
    Builder alertBuilder = new Builder(context);
    alertBuilder.setTitle(title);
    alertBuilder.setMessage(text);
    alertBuilder.create().show();
}
 
Example 19
Source File: Util.java    From Klyph with MIT License 3 votes vote down vote up
/**
 * Display a simple alert dialog with the given text and title.
 *
 * @param context
 *          Android context in which the dialog should be displayed
 * @param title
 *          Alert dialog title
 * @param text
 *          Alert dialog message
 */
public static void showAlert(Context context, String title, String text) {
    Builder alertBuilder = new Builder(context);
    alertBuilder.setTitle(title);
    alertBuilder.setMessage(text);
    alertBuilder.create().show();
}
 
Example 20
Source File: Util.java    From HypFacebook with BSD 2-Clause "Simplified" License 3 votes vote down vote up
/**
 * Display a simple alert dialog with the given text and title.
 *
 * @param context
 *          Android context in which the dialog should be displayed
 * @param title
 *          Alert dialog title
 * @param text
 *          Alert dialog message
 */
@Deprecated
public static void showAlert(Context context, String title, String text) {
    Builder alertBuilder = new Builder(context);
    alertBuilder.setTitle(title);
    alertBuilder.setMessage(text);
    alertBuilder.create().show();
}