How to add dynamic data in the renderer created using UI builder?

北战南征 提交于 2019-12-02 07:07:58

问题


How to add dynamic data in the renderer created using UI builder?

create a render from ui builder and dynamic data to populate list.

protected boolean initListModelList(List cmp) {

cmp.setModel(new com.codename1.ui.list.DefaultListModel(new String[] {"Firstname", "LastName", "Email"})); return true; }


回答1:


The renderer doesn't contain the data only the logic for presenting the data. The model is the one that contains the data.

To create a renderer check out this: http://www.codenameone.com/how-do-i---create-a-list-of-items-the-hard-way-gui-builder-renderer.html

In that case your model needs to contain hashtables or maps with the keys being the names of the components and the values being the values for the specific entry.

To update the model dynamically just use setItemAt on the DefaultListModel.



来源:https://stackoverflow.com/questions/24134121/how-to-add-dynamic-data-in-the-renderer-created-using-ui-builder

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!