Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ecommerce App in CodenameOne

Tags:

codenameone

Hi I am a newbie in CodenameOne am now creating a eCommerce app using CodenameOne resource editor ,I have used multilist for displaying products . I have checked the checkbox feature wherein I got the checkbox for all my items .My question here is by code in statemachine how do I get the name of product checked by the user and how to get whether the checkbox is checked or not .I tried implementing findMultiList().getSelected() but it returns always true if I check r uncheck.

Please help me also it would be great if you could tell me how to integrate google drive in my project because I need to pull data from excel sheet and populate it in the list.

like image 626
user3517929 Avatar asked Jun 21 '26 11:06

user3517929


1 Answers

You need to get the model and traverse the elements within it:

ListModel<Map<String, Object>> model = (ListModel<Map<String, Object>>)findMultiList(c).getModel();
ArrayList<Map<String, Object>> items = new ArrayList<>();
for(int iter = 0 ; iter < model.getSize() ; iter++) {
   Map<String, Object> current = model.getItemAt(iter);
   String checked = (String)current.get("emblem");
   if(checked != null && "true".equals(checked)) {
       items.add(current);
   }
}

I haven't tried this code but it should work. Notice that the name "emblem" is the default name used for the MultiButton/MultiList but you can change it to be anything.

You can place a break point on the for loop and inspect the map elements as you traverse them to see how this works.

like image 177
Shai Almog Avatar answered Jul 01 '26 12:07

Shai Almog



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!