1
votes

I need to create a calendar with different background colors depending on the content of the daybuttons, how can i make the colors fix : unchanged when selecting another date using codenameone.

i tried a simple modification but when selecting a button the colors turn back to white as configured in the theme (i use UI builder)

@Override
    protected void updateButtonDayDate(Button dayButton, int year, int   currentMonth, int day) {
        //dayButton.setUIID("Container");
        dayButton.getAllStyles().setPaddingTop(3);
        dayButton.getAllStyles().setPaddingBottom(3);
        dayButton.getAllStyles().setBgColor(ColorUtil.BLUE);
}
1

1 Answers

1
votes

Try setting setChangesSelectedDateEnabled(false) also make sure that the button doesn't have a border and that it's opaque by doing this:

Style s = dayButton.getAllStyles();
s.setPaddingTop(3);
s.setPaddingBottom(3);
s.setBgColor(ColorUtil.BLUE);
s.setBgTransparency(255);
s.setBorder(null);