My implementation :
================

public void search(){
    
    Form hi = new Form("Auto Complete", new BoxLayout(BoxLayout.Y_AXIS));
    // List list = new 
com.codename1.ui.List(createGenericListCellRendererModelData());
    
    
    
    Vector v = new Vector();
    for( int i =0; i<10 ; i++){
    
    Hashtable h = new Hashtable();
        h.put("name","Short-"+i);            
                 h.put("add","Kolkata-70005"+i);
                 
                 v.addElement(h);
    }
    
    //AutoCompleteTextField ac = new AutoCompleteTextField("Short", 
"Shock", "Sholder", "Shrek");
    final DefaultListModel options = new DefaultListModel(v);
    //  MyAutoCompleteTextField ac = new MyAutoCompleteTextField(options) ;
    AutoCompleteTextField ac = new AutoCompleteTextField(options);
      
    //======================
            ac.setMinimumElementsShownInPopup(5);
            ac.setCompletionRenderer(new 
GenericListCellRenderer(createGenericRendererContainer(), 
createGenericRendererContainer()));
            hi.add(ac);
            
            hi.show();
    
    }


  private Container createGenericRendererContainer() {
       Label name = new Label();
       name.setFocusable(true);
       name.setName("name");
       Label add = new Label();
       add.setFocusable(true);
       add.setName("add");
       
      /* CheckBox selected = new CheckBox();
       selected.setName("Selected");
       selected.setFocusable(true);*/
       
    //   System.out.println("in renderer"+name.getText().toString());
       
       Container c = BorderLayout.center(name).
              add(BorderLayout.SOUTH, add);
             //  add(BorderLayout.WEST, selected);*/
       c.setUIID("ListRenderer");
       return c;
    }




The output:
<https://lh3.googleusercontent.com/-nIBneJLhc_I/WA8ByKCN-2I/AAAAAAAAGPg/myDPXI3_Lacu4T3sqGgZtGjf8rUaIbnTgCLcB/s1600/search1.png>

After selection it's *Throwing the following error*:

java.lang.ClassCastException: java.util.Hashtable cannot be cast to 
java.lang.String
at 
com.codename1.ui.AutoCompleteTextField$4.actionPerformed(AutoCompleteTextField.java:324)
at 
com.codename1.ui.util.EventDispatcher.fireActionSync(EventDispatcher.java:459)
at 
com.codename1.ui.util.EventDispatcher.fireActionEvent(EventDispatcher.java:362)
at com.codename1.ui.List.fireActionEvent(List.java:1563)
at com.codename1.ui.List.pointerReleasedImpl(List.java:2046)
at com.codename1.ui.List.pointerReleased(List.java:2056)
at com.codename1.ui.Form.pointerReleased(Form.java:2623)
at com.codename1.ui.Component.pointerReleased(Component.java:3226)
at com.codename1.ui.Display.handleEvent(Display.java:2022)
at com.codename1.ui.Display.edtLoopImpl(Display.java:1067)
at com.codename1.ui.Display.mainEDTLoop(Display.java:996)
at com.codename1.ui.RunnableWrapper.run(RunnableWrapper.java:120)
at com.codename1.impl.CodenameOneThread.run(CodenameOneThread.java:176)


## the addPopup() method also private so I can not modify it.
## Filter will be based on name.



 

-- 
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/bd83e4b0-c9b3-44b4-9154-fee3dc2d31fc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to