vendredi 21 juin 2019

How to get know if a checkbox has been selected in a dynamic UI in codenameone

I have a container with dynamic UI components including checkboxes. How can I know the selection status of a particular component?

Using iSelected() doesn't work as it is always false because it seems to pick the last checkbox in the list which returns false since it is unslected.


I am able to get the checkbox at a particular indext in the parent component but once I have it there is no "iSelected" option on it. So I use a dirty way by tokenizing the string representing the component to get to the selected statsus. There must be a better way.

```System.out.println("Checkbox Data "+cnt_tablerow[Integer.parseInt(lbl_memberno.getName())].getComponentAt(0)); //Checkbox Data: CheckBox[x=0 y=0 width=63 height=152 name=524, text = , gap = 2, selected = true]

```String str_chkbox = StringUtil.tokenize(StringUtil.tokenize(cnt_tablerow[Integer.parseInt(lbl_memberno.getName())].getComponentAt(0), ']').get(0), '[').get(1);

```String str_status = StringUtil.tokenize(StringUtil.tokenize(str_chkbox, ',').get(3), '=').get(1).trim();

```if(str_status == "true"){}




Aucun commentaire:

Enregistrer un commentaire