AlertDialog.Builder setNegativeButton - 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 setNegativeButton method.

This code example shows how to use the following methods:setIcon, setNegativeButton, setPositiveButton, setView
		view.setPadding(Math.round(mColorPicker.getDrawingOffset()), 0, Math.round(mColorPicker.getDrawingOffset()), 0);
 
		final int val = getValue();
		mColorPicker.setColor(val, true);
		mColorPicker.setAlphaSliderVisible(mAlphaSliderEnabled);
		builder.setView(view);
		builder.setIcon(new BitmapDrawable(context.getResources(), getColorPreviewBitmap(context, val)));
		builder.setPositiveButton(android.R.string.ok, this);
		builder.setNegativeButton(android.R.string.cancel, null);
	} 
 
	@Override 
	protected void onSetInitialValue(final boolean restoreValue, final Object defaultValue) {
		if (isPersistent() && defaultValue instanceof Integer) {
			persistInt(restoreValue ? getValue() : (Integer) defaultValue);
		} 
	} 
 
	private int getValue() { 
		try { 
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:setCancelable, setIcon, setMessage, setNegativeButton, setPositiveButton
This code example shows how to use the following methods:create, setMessage, setNegativeButton, setPositiveButton, setTitle
import android.content.DialogInterface.OnClickListener; 
 
public class AlertDialogFactory { 
	public static AlertDialog getConfirmDialog(Context ctx, String title,
			String msg, final DialogCallback ok) {
		AlertDialog.Builder builder = new Builder(ctx);
		builder.setTitle(title);
		builder.setMessage(msg);
		builder.setPositiveButton("确定", new OnClickListener() {
 
			public void onClick(DialogInterface dialog, int which) {
				ok.execute();
			} 
		}); 
		builder.setNegativeButton("取消", new OnClickListener() {
			 
			public void onClick(DialogInterface dialog, int which) {
				ok.cancle();
			} 
		}); 

6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
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 
     *  
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:create, setMessage, setNegativeButton, setPositiveButton, setTitle
{ 
	public static void dialogBuilder( Activity instance, String title, 
			String message,
			final DialogCallBack callBack)
	{ 
        AlertDialog.Builder builder = new Builder(instance);
        builder.setMessage( message );  
        builder.setTitle( title );  
        builder.setPositiveButton("OK",  
        new android.content.DialogInterface.OnClickListener() 
        {   
            public void onClick(DialogInterface dialog, int which) {  
                dialog.dismiss();  
                callBack.callBack();
            }   
        });  
         
        builder.setNegativeButton("Cancel",  
        new android.content.DialogInterface.OnClickListener() 
        {   

6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:create, setIcon, setMessage, setNegativeButton, setPositiveButton
    } 
 
    @Override 
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        Bundle args = getArguments();
        Builder b = new Builder(getActivity());
        b.setTitle(args.getString(BUNDLE_TITLE));
        b.setMessage(args.getString(BUNDLE_MESSAGE));
        b.setIcon(android.R.drawable.ic_dialog_alert);
        setCancelable(true);
        b.setPositiveButton(args.getString(BUNDLE_POSITIVE_BUTTON_TEXT), mPositiveOnClickListener);
        b.setNegativeButton(args.getString(BUNDLE_NEGATIVE_BUTTON_TEXT), mNegativeOnClickListener);
        return b.create();
    } 
 
    public static class QuestionDialogFragmentBuilder { 
 
        private FragmentActivity mActivity;
        private String mTitle;
        private String mMessage;
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:create, setMessage, setNegativeButton, setPositiveButton, setTitle
	 */ 
	public static void dialogBuilder(Activity instance, String title, 
			String message,
			final DialogCallBack callBack)
	{ 
        AlertDialog.Builder builder = new Builder(instance);
        builder.setMessage(message);  
        builder.setTitle(title);  
        builder.setPositiveButton("确认",  
        new android.content.DialogInterface.OnClickListener() 
        {   
            public void onClick(DialogInterface dialog, int which) {  
                dialog.dismiss();  
                callBack.callBack();
            }   
        });  
         
        builder.setNegativeButton("取消",  
        new android.content.DialogInterface.OnClickListener() 
        {   

6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:setMessage, setNegativeButton, setPositiveButton, setTitle, show
	private void ExitSystem() { 
		ShowExitDialog(); 
	} 
	 
	private void ShowExitDialog() { 
		LogoutDialogBuilder = new AlertDialog.Builder(LoginUI.this);
		LogoutDialogBuilder.setTitle("�˳���ʾ");
		LogoutDialogBuilder.setMessage("�����Ƿ���Ҫ�˳�\n�ǣ��밴ȷ��\n�����밴ȡ��");
		LogoutDialogBuilder.setPositiveButton("ȷ��", new DialogPositiveButtonListener());
		LogoutDialogBuilder.setNegativeButton("ȡ��", null);
		LogoutDialogBuilder.show();
	} 
	 
	private void DisplayErrorMessage() { 
		Toast.makeText(this, "�û�������������", Toast.LENGTH_SHORT).show();
	}	 
	 
	class ButtonListener implements OnClickListener
	{ 
		@Override 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
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
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:setMessage, setNegativeButton, setTitle, show
	 *  
	 * @param context 
	 * @param message 
	 */ 
	public void alertMessage(Context context, String message) {
		Builder dialog = new AlertDialog.Builder(context);
		dialog.setTitle("알 림");
		dialog.setMessage(message);
		dialog.setNegativeButton("닫기", new OnClickListener() {
			@Override 
			public void onClick(DialogInterface dialog, int which) {
				dialog.dismiss();
			} 
		}); 
		dialog.show();
	} 
	 
	/** 
	 * 기본적인 프로그래스 다이얼로그를 리턴한다. 
	 *  
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java

Related AlertDialog.Builder setNegativeButton Questions & Answers:

Other AlertDialog.Builder setNegativeButton Examples

171:	
172:			// on pressing cancel button
173:			alertDialog.setNegativeButton("Cancel",
174:					new DialogInterface.OnClickListener() {
175:						public void onClick(DialogInterface dialog, int which) {

Read More

168:	 
169:	        // on pressing cancel button
170:	        alertDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
171:	            public void onClick(DialogInterface dialog, int which) {
172:	            dialog.cancel();

Read More

30:	 
31:	        // on pressing cancel button
32:	        alertDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
33:	            public void onClick(DialogInterface dialog, int which) {
34:	            dialog.cancel();

Read More

setNegativeButton Method Overview
Set a listener to be invoked when the negative button of the dialog is pressed.
See Code Examples for other Android AlertDialog.Builder Methods: