I created a Container that resembles the Chip Android control. In fact I just need that a button acts like a CheckBox or ToggleButton.
In my implementation the button has rounded corners and it has a check symbol when it is checked (checked=true). That symbols is put at the beginning of the label of the button. I tried by just changing the text of the button, but it was not updated, then in the code below the button is removed and then recreated. But it does not work yet: what I experience is that the control gets updated only if I enter a TextField and click on the button again. Calling invalidate() is of no help. Note that this is similar to what happened with the BrowserComponent. Is it something related to UI refresh? However, what's wrong with this code? import com.codename1.ui.Button; import com.codename1.ui.Container; import com.codename1.ui.events.ActionEvent; import com.codename1.ui.events.ActionListener; import com.codename1.ui.layouts.BoxLayout; import com.codename1.ui.plaf.RoundBorder; public class MyChip extends Container { boolean checked; Button button; String label; public void setAppearance() { String labelText=label; if (button!=null) button.remove(); if (checked) labelText="✓ "+label; button=new Button(labelText); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { setChecked(!checked); } }); button.getAllStyles().setBorder(RoundBorder.create() .rectangle(true) .color(0xaaaaaa)); add(button); } public MyChip(String labelParam) { this.label=labelParam; setLayout(BoxLayout.x()); setChecked(false); } public void setChecked(boolean state) { checked=state; setAppearance(); } public boolean isChecked() { return checked; } } -- You received this message because you are subscribed to the Google Groups "CodenameOne Discussions" group. To unsubscribe from this group and stop receiving emails from it, send an email to codenameone-discussions+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/codenameone-discussions/84c3e93d-89c8-4ecf-a940-b59fbe0bdbafo%40googlegroups.com.