简体   繁体   中英

how to update a list content in lwuit at runtime

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.

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM