Hi, Im trying to display some json records using a MultiList. I followed
what was done here https://www.codenameone.com/manual/graphics.html but
mine is returning only one record (Please see the attached file). I'm using
the old GUI builder.
Below is my code. Please kindly show me where i'm wrong.
@Override
protected void beforeFormA(Form f) {
Style s = UIManager.getInstance().getComponentStyle("Button");
FontImage p =
FontImage.createMaterial(FontImage.MATERIAL_PORTRAIT, s);
EncodedImage placeholder =
EncodedImage.createFromImage(p.scaled(p.getWidth() * 3, p.getHeight() * 4),
false);
getattractive();//fetch results from webservice and store inside
response variable
ArrayList arr = (ArrayList) response.get("results");
for (Object m:arr){
Map ma = (Map)m;
address =(String) ma.get("formatted_address");
name=(String)ma.get("name");
icon=(String)ma.get("icon");
ArrayList<Map<String, Object>> data = new ArrayList<>();
data.add(createListEntry(name,address,icon));
DefaultListModel<Map<String, Object>> model = new
DefaultListModel<>(data);
MultiList ml = new MultiList(model);
ml.getUnselectedButton().setIconName("icon_URLImage");
ml.getSelectedButton().setIconName("icon_URLImage");
ml.getUnselectedButton().setIcon(placeholder);
ml.getSelectedButton().setIcon(placeholder);
f.add(BorderLayout.CENTER, ml);
}
}
private Map<String, Object> createListEntry(String name, String addr,
String coverURL) {
Map<String, Object> entry = new HashMap<>();
entry.put("Line1", name);
entry.put("Line2", addr);
entry.put("icon_URLImage", coverURL);
entry.put("icon_URLImageName", name);
return entry;
--
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 [email protected].
Visit this group at https://groups.google.com/group/codenameone-discussions.
To view this discussion on the web visit
https://groups.google.com/d/msgid/codenameone-discussions/d85790ff-9df5-48fb-9d88-5bf9f055ddc3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.