Android 更改Sweet alert中的按钮样式

Android 更改Sweet alert中的按钮样式,android,android-alertdialog,sweetalert,Android,Android Alertdialog,Sweetalert,我正在使用android的SweetAlert对话框 在“成功”对话框中,我想删除“确定”按钮并更改其样式。请解释如何删除“确定”按钮 我在单击按钮时调用方法 new SweetAlertDialog(this, SweetAlertDialog.SUCCESS_TYPE) .setTitleText("Good job!") .setContentText("You clicked the button!") .show(); 试试这个 dialog.findVie

我正在使用android的SweetAlert对话框

在“成功”对话框中,我想删除“确定”按钮并更改其样式。请解释如何删除“确定”按钮

我在单击按钮时调用方法

new SweetAlertDialog(this, SweetAlertDialog.SUCCESS_TYPE)
    .setTitleText("Good job!")
    .setContentText("You clicked the button!")
    .show();
试试这个

dialog.findViewById(R.id.confirm_button).setVisibility(View.GONE);
更多详细信息:

试试这个

dialog.findViewById(R.id.confirm_button).setVisibility(View.GONE);

更多详细信息:

尝试设置“确定”按钮的可见性

SweetAlertDialog sweetdialog = new SweetAlertDialog(this, SweetAlertDialog.SUCCESS_TYPE)
.setTitleText("Good job!")
.setContentText("You clicked the button!")
.show();


Button myBtn = (Button) sweetdialog.findViewById(R.id.confirm_button).setVisibility(View.GONE);

尝试设置“确定”按钮

SweetAlertDialog sweetdialog = new SweetAlertDialog(this, SweetAlertDialog.SUCCESS_TYPE)
.setTitleText("Good job!")
.setContentText("You clicked the button!")
.show();


Button myBtn = (Button) sweetdialog.findViewById(R.id.confirm_button).setVisibility(View.GONE);

您可以使用简单的策略从甜蜜警报访问按钮

SweetAlertDialog alertDialog = new SweetAlertDialog(MainActivity.this,SweetAlertDialog.SUCCESS_TYPE);
alertDialog.setTitleText("Good job!");
alertDialog.setContentText("You clicked the button!");
alertDialog.show();

Button btn = (Button) alertDialog.findViewById(R.id.confirm_button);
btn.setBackgroundColor(ContextCompat.getColor(UserSignupActivity.this,R.color.colorPrimary));

访问后,您可以设置样式,也可以根据需要隐藏按钮。

您可以使用简单的策略从甜蜜警报中访问按钮

SweetAlertDialog alertDialog = new SweetAlertDialog(MainActivity.this,SweetAlertDialog.SUCCESS_TYPE);
alertDialog.setTitleText("Good job!");
alertDialog.setContentText("You clicked the button!");
alertDialog.show();

Button btn = (Button) alertDialog.findViewById(R.id.confirm_button);
btn.setBackgroundColor(ContextCompat.getColor(UserSignupActivity.this,R.color.colorPrimary));

访问后,您可以根据需要设置样式或隐藏按钮。

使用以下代码,而不是
新建SweetAlertDialog(此为SweetAlertDialog.SUCCESS\u TYPE)

SweetAlertDialog myDialog = new SweetAlertDialog(this, SweetAlertDialog.SUCCESS_TYPE)
.setTitleText("yourtext")
.setContentText("yourtext2")
.show();

myDialog.findViewById(R.id.confirm_button).setVisibility(View.GONE);

使用以下代码,而不是
新建SweetAlertDialog(此,SweetAlertDialog.SUCCESS\u TYPE)

SweetAlertDialog myDialog = new SweetAlertDialog(this, SweetAlertDialog.SUCCESS_TYPE)
.setTitleText("yourtext")
.setContentText("yourtext2")
.show();

myDialog.findViewById(R.id.confirm_button).setVisibility(View.GONE);

您可以将颜色从color.xml更改为所需的十六进制值

    <color name="blue_btn_bg_pressed_color">#96BFD2</color>
    <color name="blue_btn_bg_color">#AEDEF4</color>
    <color name="button_text_color">#FFFFFF</color>
    <color name="error_stroke_color">#F27474</color>
    <color name="float_transparent">#00000000</color>
    <color name="gray_btn_bg_color">#D0D0D0</color>
    <color name="gray_btn_bg_pressed_color">#B6B6B6</color>
    <color name="material_blue_grey_80">#ff37474f</color>
    <color name="material_blue_grey_90">#ff263238</color>
    <color name="material_blue_grey_95">#ff21272b</color>
    <color name="material_deep_teal_20">#ff80cbc4</color>
    <color name="material_deep_teal_50">#ff009688</color>
    <color name="red_btn_bg_color">#DD6B55</color>
    <color name="red_btn_bg_pressed_color">#CD5B55</color>
    <color name="success_stroke_color">#A5DC86</color>
    <color name="sweet_dialog_bg_color">#FFFFFF</color>
    <color name="text_color">#575757</color>
    <color name="trans_success_stroke_color">#33A5DC86</color>
    <color name="warning_stroke_color">#F8BB86</color>
#96BFD2
#AEDEF4
#FFFFFF
#F27474
#00000000
#D0D0D0
#B6B6B6
#ff37474f
#ff263238
#ff21272b
#ff80cbc4
#ff009688
#DD6B55
#CD5B55
#A5DC86
#FFFFFF
#575757
#33A5DC86
#F8BB86

您可以将color.xml中的颜色更改为所需的十六进制值

    <color name="blue_btn_bg_pressed_color">#96BFD2</color>
    <color name="blue_btn_bg_color">#AEDEF4</color>
    <color name="button_text_color">#FFFFFF</color>
    <color name="error_stroke_color">#F27474</color>
    <color name="float_transparent">#00000000</color>
    <color name="gray_btn_bg_color">#D0D0D0</color>
    <color name="gray_btn_bg_pressed_color">#B6B6B6</color>
    <color name="material_blue_grey_80">#ff37474f</color>
    <color name="material_blue_grey_90">#ff263238</color>
    <color name="material_blue_grey_95">#ff21272b</color>
    <color name="material_deep_teal_20">#ff80cbc4</color>
    <color name="material_deep_teal_50">#ff009688</color>
    <color name="red_btn_bg_color">#DD6B55</color>
    <color name="red_btn_bg_pressed_color">#CD5B55</color>
    <color name="success_stroke_color">#A5DC86</color>
    <color name="sweet_dialog_bg_color">#FFFFFF</color>
    <color name="text_color">#575757</color>
    <color name="trans_success_stroke_color">#33A5DC86</color>
    <color name="warning_stroke_color">#F8BB86</color>
#96BFD2
#AEDEF4
#FFFFFF
#F27474
#00000000
#D0D0D0
#B6B6B6
#ff37474f
#ff263238
#ff21272b
#ff80cbc4
#ff009688
#DD6B55
#CD5B55
#A5DC86
#FFFFFF
#575757
#33A5DC86
#F8BB86
这同样有效

SweetAlertDialog sweetdialog = new SweetAlertDialog(this, SweetAlertDialog.SUCCESS_TYPE)
.setTitleText("Good job!")
.setContentText("You clicked the button!")
.show();

 sweetdialog.getButton(SweetAlertDialog.BUTTON_CONFIRM).setBackgroundColor(getResources().getColor(R.color.colorPrimaryDark));
这同样有效

SweetAlertDialog sweetdialog = new SweetAlertDialog(this, SweetAlertDialog.SUCCESS_TYPE)
.setTitleText("Good job!")
.setContentText("You clicked the button!")
.show();

 sweetdialog.getButton(SweetAlertDialog.BUTTON_CONFIRM).setBackgroundColor(getResources().getColor(R.color.colorPrimaryDark));

您必须创建SweetAlertDialog对象才能访问ok按钮您必须创建SweetAlertDialog对象才能访问ok按钮这太棒了,非常简单。这太棒了,非常简单。Workign解决方案,ThanksWorkign解决方案,谢谢