Codigami / CFAlertDialog

MIT License
224 stars 47 forks source link

How to arrange the buttons in a row? #29

Open EfremovAV opened 5 years ago

EfremovAV commented 5 years ago

I can't place several buttons in one row. How can I do that?

keskin commented 3 years ago

You can create a custom layout and attach it to the dialog by using setFooterView

Hope it helps

LayoutInflater inflater = this.getLayoutInflater();
final View footer = inflater.inflate(R.layout.dialog_alert_footer_layout, null);
footer.findViewById(R.id.yesButton).setOnClickListener(v -> { 
    // 
});
footer.findViewById(R.id.noButton).setOnClickListener(v -> {
    // 
});

CFAlertDialog.Builder builder = new CFAlertDialog.Builder(this)
        .setDialogStyle(CFAlertDialog.CFAlertStyle.ALERT)
        .setTitle(title)
        .setMessage(message)
        .setCancelable(false)
        .setTextGravity(Gravity.CENTER_HORIZONTAL)
        .setHeaderView(header)
        .setFooterView(footer)