is that code for a dynamic list is true?

9 views
Skip to first unread message

Sondes Hammami

unread,
Apr 20, 2017, 6:53:10 AM4/20/17
to CodenameOne Discussions
If you are experiencing an issue please mention the full platform your issue applies to:
IDE: NetBeans/Eclipse/IDEA
Desktop OS
Simulator
Device

  protected boolean initListModelMultilist(List cmp){
       
    Vector vec =new Vector();
    Hashtable h=new Hashtable();
    
    int i;
  for(i=1;i>1;i++){
  
  
    vec.addElement(vec);
    cmp.setModel(new DefaultListModel(vec));
    
        
 return true;
  }

Steve Hannah

unread,
Apr 20, 2017, 1:33:45 PM4/20/17
to codenameone...@googlegroups.com
Many problems with this code. (Loop never runs, vector added to itself (even if loop ran), setting model in each iteration of loop, etc..).

Try something like this:

protected boolean initListModelMultilist(List cmp){
       
    cmp.setModel(new DefaultListModel("Item 1", "Item 2", "Item 3"));
    
        
 return true;
  }


Steve

--
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+unsub...@googlegroups.com.
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/6fdb78b2-4cf2-43b4-b23e-3e08e284344e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Steve Hannah
Software Developer
Codename One
Reply all
Reply to author
Forward
0 new messages