Java Code Examples for android.app.AlertDialog#setIcon()

The following examples show how to use android.app.AlertDialog#setIcon() . 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: ScheduledDownloadsDialog.java    From aptoide-client with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity());
    final AlertDialog scheduleDownloadDialog = dialogBuilder.create();
    scheduleDownloadDialog.setTitle(getText(R.string.schDwnBtn));
    scheduleDownloadDialog.setIcon(android.R.drawable.ic_dialog_alert);
    scheduleDownloadDialog.setCancelable(false);
    scheduleDownloadDialog.setMessage(getText(R.string.schDown_install));
    scheduleDownloadDialog.setButton(Dialog.BUTTON_POSITIVE, getString(android.R.string.yes), new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            if (callback!=null) callback.onOkClick();
        }
    });
    scheduleDownloadDialog.setButton(Dialog.BUTTON_NEGATIVE, getString(android.R.string.no), new Dialog.OnClickListener() {
        @Override
        public void onClick(DialogInterface arg0, int arg1) {
            if (callback!=null) callback.onCancelClick();
        }
    });


    return scheduleDownloadDialog;
}
 
Example 2
Source File: AlertDialogManager.java    From odm with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Function to display simple Alert Dialog
 * 
 * @param context
 *            - application context
 * @param title
 *            - alert dialog title
 * @param message
 *            - alert message
 * @param status
 *            - success/failure (used to set icon) - pass null if you don't
 *            want icon
 * */
@SuppressWarnings("deprecation")
public void showAlertDialog(Context context, String title, String message, Boolean status) {
	AlertDialog alertDialog = new AlertDialog.Builder(context).create();
	// Setting Dialog Title
	alertDialog.setTitle(title);
	// Setting Dialog Message
	alertDialog.setMessage(message);
	if (status != null)
		// Setting alert dialog icon
		alertDialog.setIcon((status) ? R.drawable.success : R.drawable.fail);
	// Setting OK Button
	alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
		@Override
		public void onClick(DialogInterface dialog, int which) {
		}
	});
	// Showing Alert Message
	alertDialog.show();
}
 
Example 3
Source File: IconContextMenu.java    From screenstandby with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Create menu
 * @return
 */
public Dialog createMenu(String menuItitle) {
	final AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
       builder.setTitle(menuItitle);
       builder.setAdapter(menuAdapter, new DialogInterface.OnClickListener() {
		@Override
		public void onClick(DialogInterface dialoginterface, int i) {
			IconContextMenuItem item = (IconContextMenuItem) menuAdapter.getItem(i);
			
			if (clickHandler != null) {
				clickHandler.onClick(item.actionTag);
			}
		}
	});

       builder.setInverseBackgroundForced(true);

       AlertDialog dialog = builder.create();
       dialog.setOnCancelListener(this);
       dialog.setOnDismissListener(this);
       dialog.setIcon(R.drawable.appico);
       return dialog;
}
 
Example 4
Source File: BlurNavigationDrawerActivity.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();
    if (id == R.id.about) {
        AlertDialog alertDialog = new AlertDialog.Builder(this).create();
        alertDialog.setTitle(getString(R.string.app_name));
        alertDialog.setIcon(android.R.drawable.ic_dialog_info);
        alertDialog.setMessage("Developed by Basilis Charalampakis\n\n" +
                "GitHub     : http://github.com/charbgr\n" +
                "Linkedin  : http://linkedin.com/in/charalampakisbasilis/");
        alertDialog.show();
        return true;
    }
    return super.onOptionsItemSelected(item);
}
 
Example 5
Source File: BlurNavigationDrawerActivity.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();
    if (id == R.id.about) {
        AlertDialog alertDialog = new AlertDialog.Builder(this).create();
        alertDialog.setTitle(getString(R.string.app_name));
        alertDialog.setIcon(android.R.drawable.ic_dialog_info);
        alertDialog.setMessage("Developed by Basilis Charalampakis\n\n" +
                "GitHub     : http://github.com/charbgr\n" +
                "Linkedin  : http://linkedin.com/in/charalampakisbasilis/");
        alertDialog.show();
        return true;
    }
    return super.onOptionsItemSelected(item);
}
 
Example 6
Source File: MainActivity.java    From BlurNavigationDrawer with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();
    if (id == R.id.about) {
        AlertDialog alertDialog = new AlertDialog.Builder(this).create();
        alertDialog.setTitle(getString(R.string.app_name));
        alertDialog.setIcon(android.R.drawable.ic_dialog_info);
        alertDialog.setMessage("Developed by Basilis Charalampakis\n\n" +
                "GitHub     : http://github.com/charbgr\n" +
                "Linkedin  : http://linkedin.com/in/charalampakisbasilis/");
        alertDialog.show();
        return true;
    }
    return super.onOptionsItemSelected(item);
}
 
Example 7
Source File: EasyWayLocation.java    From EasyWayLocation with Apache License 2.0 5 votes vote down vote up
public void showAlertDialog(String title, String message, Drawable drawable) {
    AlertDialog alertDialog = new AlertDialog.Builder(context).create();
    alertDialog.setTitle(title);
    if (drawable != null) {
        alertDialog.setIcon(drawable);
    }
    alertDialog.setMessage(message);
    alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, context.getString(R.string.ok),
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });
    alertDialog.show();
}
 
Example 8
Source File: AlertDialogManager.java    From restaurant-bot with GNU General Public License v3.0 5 votes vote down vote up
public void showAlertDialog(Context context, String title, String message,
                            Boolean status) {
    AlertDialog alertDialog = new AlertDialog.Builder(context).create();
    alertDialog.setTitle(title);
    alertDialog.setMessage(message);
    if(status != null)
        alertDialog.setIcon((status) ? R.drawable.success : R.drawable.fail);
    alertDialog.setButton("Тийм", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
        }
    });
    alertDialog.show();
}
 
Example 9
Source File: MeasurementView.java    From openScale with GNU General Public License v3.0 5 votes vote down vote up
private void prepareInputDialog(final AlertDialog dialog) {
    dialog.setTitle(getName());
    dialog.setIcon(getIcon());

    final View input = getInputView();

    FrameLayout fl = dialog.findViewById(android.R.id.custom);
    fl.removeAllViews();
    fl.addView(input, new LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.WRAP_CONTENT));

    View.OnClickListener clickListener = new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (view == dialog.getButton(DialogInterface.BUTTON_POSITIVE)
                && !validateAndSetInput(input)) {
                return;
            }
            dialog.dismiss();
        }
    };

    dialog.getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener(clickListener);
    dialog.getButton(DialogInterface.BUTTON_NEGATIVE).setOnClickListener(clickListener);

    final MeasurementView next = getNextView();
    if (next != null) {
        dialog.getButton(DialogInterface.BUTTON_NEUTRAL).setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (validateAndSetInput(input)) {
                    next.prepareInputDialog(dialog);
                }
            }
        });
    }
    else {
        dialog.getButton(DialogInterface.BUTTON_NEUTRAL).setVisibility(GONE);
    }
}