0

I have designed a lwuit form with a textfield and a list bottom of it. Now, I want following functionality:

every time user changes a textfield content, list should be refreshed (like autocomlplete feature) but I don't know how to refresh a list? for creating a list I have used following code:

choicelists = createList(urbanplacechoiceGroup, List.VERTICAL, new PlaceRenderer());

and for listening to texhfield changes:

Urbanareas_textpublic.addDataChangeListener(new DataChangedListener() {

        public void dataChanged(int type, int index) {
            System.out.println("text content: " + Urbanareas_textpublic.getText());
            populateurbanplacechoiceGroup();
         }
    });

urbanplacechoiceGroup is used to populate urbanplacechoiceGroup which its content used for choicelists.

I found this function and it does updating a list:

choicelists.setRenderer(new PlaceRenderer());

is it a standard way to updating list? what happened to PlaceRenderer objects which was created before? thanks.

Navid
  • 901
  • 9
  • 20

2 Answers2

1

You can use in list that work with ListCellRenderer.

This is dinamic list that use to dispalying data list.In addtional this list save up use in memory ,because he don't create a list but use data only to display.

neb1
  • 209
  • 1
  • 12
  • my PlaceRendere implemented ListCellRendere! I dont know how to update it? for example after I have updated urbanplacechoicegroup which contains my data, how could I refresh ListCellRenderer to show the changes? – Navid Apr 13 '13 at 12:19
  • i found setRenderer(...) function as I added to my question. is it a standard way? – Navid Apr 13 '13 at 13:51
  • Yes, when you want update your list. we need call this function – neb1 Apr 14 '13 at 06:22
1

See this post http://codenameone.blogspot.com/2008/06/lightweight-text-input-in-lwuit.html

It covers filtering a list dynamically, basically what you are looking for is a list model which abstracts the data of the list.

Shai Almog
  • 51,749
  • 5
  • 35
  • 65