AlertDialog.Builder setCancelable - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for AlertDialog.Builder setCancelable method.

This code example shows how to use the following methods:create, setCancelable, setIcon, setMessage, setTitle
	private Toast toast;
	 
	@Override 
	public AlertDialog show(Context context, String title, String message) {
		AlertDialog.Builder builder = makeBuilder(context);
		builder.setTitle(title);
		 
		if(drawables != null) {
			builder.setIcon(drawables.getDrawable("socialize_icon_white.png"));
		} 
		 
		if(!StringUtils.isEmpty(message)) {
			builder.setMessage(message);
		} 
		 
		builder.setCancelable(true)
		.setPositiveButton("OK", new DialogInterface.OnClickListener() {
			public void onClick(DialogInterface dialog, int id) {
				dialog.dismiss();
			} 

8
CodeRank
This code example shows how to use the following methods:setCancelable, setIcon, setMessage, setPositiveButton, setTitle
                    .getClientMessageResourceId()); 
        } else { 
            screenMessage = error.getLocalizedMessage();
        } 
 
        AlertDialog.Builder builder = new AlertDialog.Builder(activity);
        builder.setTitle(title);
        builder.setMessage(screenMessage);
        builder.setIcon(android.R.drawable.ic_dialog_alert);
        builder.setCancelable(false);
        builder.setPositiveButton(activity.getString(android.R.string.ok), new OnClickListener() {
 
            @Override 
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
            } 
        }); 
 
        return builder;
    } 
9
CodeRank
This code example shows how to use the following methods:create, setCancelable, setIcon, setMessage, setPositiveButton
     * @param iconResourceId 
     * @return 
     */ 
    public static AlertDialog newMessageDialog(final Context context, String dialogTitle,
            String screenMessage, int iconResourceId) {
        AlertDialog.Builder builder = new AlertDialog.Builder(context);
        builder.setCancelable(false);
        builder.setPositiveButton("Okay", new OnClickListener() {
 
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
            } 
        }); 
 
        builder.setTitle(dialogTitle);
        builder.setMessage(screenMessage);
        builder.setIcon(iconResourceId);
 
        return builder.create();
    } 

9
CodeRank
This code example shows how to use the following methods:create, setCancelable, setMessage, setNegativeButton, setPositiveButton
	@Override 
	protected Dialog onCreateDialog(int id) {
		switch (id) {
		case DIALOG_ALERT:
			// Create out AlterDialog 
			Builder builder = new AlertDialog.Builder(this);
			builder.setMessage("This will end the activity");
			builder.setCancelable(true);
			builder.setPositiveButton("I agree", new OkOnClickListener());
			builder.setNegativeButton("No, no", new CancelOnClickListener());
			AlertDialog dialog = builder.create();
			dialog.show();
		} 
		return super.onCreateDialog(id);
	} 
 
	private final class CancelOnClickListener implements 
			DialogInterface.OnClickListener {
		public void onClick(DialogInterface dialog, int which) {
			Toast.makeText(getApplicationContext(), "Activity will continue",
8
CodeRank
This code example shows how to use the following methods:create, setCancelable, setMessage, setNegativeButton, setPositiveButton
	 
	@Override  
	protected android.app.Dialog onCreateDialog(int id){
		switch(id){
		case DIALOG_ALERT:
			Builder builder = new AlertDialog.Builder(this);
			builder.setMessage("Do you want to end the activity?");
			builder.setCancelable(true);
			builder.setPositiveButton("This will end the activity", new OkOnClickListener());
			builder.setNegativeButton("This will resume the activity", new CancelOnClickListener());
			AlertDialog dialog = builder.create();
			dialog.show();
		} 
		return super.onCreateDialog(id);
	} 
 
 
	private final class CancelOnClickListener implements 
	DialogInterface.OnClickListener {
public void onClick(DialogInterface dialog, int which) {
6
CodeRank
This code example shows how to use the following methods:create, setCancelable, setMessage, setNegativeButton, setPositiveButton
		finish();
	} 
	 
	public Dialog onCreateDialog(int id){
		if(id == EVERBIE_ALREADY_ALIVE){
			Builder builder = new Builder(this);
			builder.setMessage("Are you sure you want to create a new Everbie? This will erase the current one");
			builder.setCancelable(true);
			builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
				public void onClick(DialogInterface dialog, int which) {
					Intent main = new Intent("com.cheesymountain.woe.NEWEVERBIEACTIVITY");
					startActivity(main);
					finish();
				} 
			}); 
			builder.setNegativeButton("No", new DialogInterface.OnClickListener() {
				public void onClick(DialogInterface dialog, int which) {
					dialog.cancel();
				} 
			}); 

6
CodeRank
This code example shows how to use the following methods:create, setCancelable, setMessage, setNegativeButton, setPositiveButton
    	switch (id){
    	case 10: 
    		// Erstellt eine Message mit Abfrage ob Beenden 
    		// wenn ja gesagt wurde wird das App beendet 
    		// wenn nein kehrt man einfach zurück 
    		Builder builder = new AlertDialog.Builder(this);
    		builder.setMessage("NetMan wirklich Beenden?");
    		builder.setCancelable(true);
    		 
    		builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
    			public void onClick(DialogInterface dialog, int which){
    				setResult(2);
    				Main.this.finish();
    			} 
    		}); 
    		builder.setNegativeButton("Nein, doch nicht!", new DialogInterface.OnClickListener() {
    			public void onClick(DialogInterface dialog, int which){
    				Toast.makeText(getApplicationContext(), "NetMan wird fortgesetzt", Toast.LENGTH_SHORT).show();
    			} 
    		}); 

6
CodeRank
This code example shows how to use the following methods:create, setCancelable, setIcon, setMessage, setNegativeButton
     * @param listener 
     * @return 
     */ 
    public static AlertDialog newYesNoDialog(final Context context, String dialogTitle,
            String screenMessage, int iconResourceId, OnClickListener listener) {
        AlertDialog.Builder builder = new AlertDialog.Builder(context);
        builder.setCancelable(false);
        builder.setPositiveButton(android.R.string.yes, listener);
        builder.setNegativeButton(android.R.string.no, listener);
 
        builder.setTitle(dialogTitle);
        builder.setMessage(screenMessage);
        builder.setIcon(iconResourceId);
 
        return builder.create();
    } 
 
    /** 
     * Creates a new AlertDialog to display a simple message 
     * 
6
CodeRank
This code example shows how to use the following methods:create, setCancelable, setMessage, setNegativeButton, setPositiveButton
  @Override 
  protected Dialog onCreateDialog(int id) {
    switch (id) {
      case DIALOG_ALERT:
        // Create out AlterDialog 
        Builder builder = new AlertDialog.Builder(this);
        builder.setMessage("This will end the activity");
        builder.setCancelable(true);
        builder.setPositiveButton("I agree", new OkOnClickListener());
        builder.setNegativeButton("No, no", new CancelOnClickListener());
        AlertDialog dialog = builder.create();
        dialog.show();
        return dialog;
      case DIALOG_DOWNLOAD_PROGRESS:
        progressDialog = new ProgressDialog(this);
        progressDialog.setMessage("Waiting Dialog");
        progressDialog.setIndeterminate(false);
        progressDialog.setMax(100);
        progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        progressDialog.setCancelable(true);
7
CodeRank
This code example shows how to use the following methods:create, setCancelable, setMessage, setNeutralButton
		 
		 
		final Vibrator vib = (Vibrator) this.getSystemService(Service.VIBRATOR_SERVICE);
		 
		if(ad==null){
			Builder ad_b = new AlertDialog.Builder(this);
			ad_b.setMessage("Hi there!");
			ad_b.setCancelable(false);
			ad_b.setNeutralButton("Close", new DialogInterface.OnClickListener() {
				public void onClick(DialogInterface d, int i) {
					 
					Toast.makeText(XAlert.this, "test", Toast.LENGTH_SHORT).show();
					vib.cancel();
					kl.reenableKeyguard();
					XAlert.this.finish();
					 
				} 
			}); 
			ad = ad_b.create();
		} 

6
CodeRank

Related AlertDialog.Builder setCancelable Questions & Answers:

setCancelable Method Overview
Sets whether the dialog is cancelable or not.
See Code Examples for other Android AlertDialog.Builder Methods: