简体   繁体   English

刷新lwuit中的列表内容

[英]refresh list contents in lwuit

I am developing an application that provides a List of items to user on the basis of choosen category from ComboBox . 我正在开发一个应用程序,该应用程序根据从ComboBox中选择的类别向用户提供项目List I am implementing this in lwuit. 我正在用lwuit实现它。 The problem is , when i change the selected item from ComboBox , the updated list do not appear on screen. 问题是,当我从ComboBox更改所选项目时,更新的列表不会出现在屏幕上。 How to refresh the List within the screen. 如何在屏幕内刷新List and the selected item from ComboBox must be maintained when the user comes back to this Form . 当用户返回到此Form时,必须保留从ComboBox选择的项目。

1)Add an selection listener on the combo box (combox.addselectionlistener(new Sele....)) 1)在组合框上添加选择侦听器(combox.addselectionlistener(new Sele ....))

2)get the selected item and its index on the event of selection changed 2)在选择事件发生时获取所选项目及其索引

3)Assign a new data source to your list based on the selection with : 3)根据选择,将新的数据源分配给您的列表:

yourList = new List(java.lang.Object[] items);// this can be an array of strings.

so if you have 3 items in combo box, you should have 3 different string arrays for each item of the combo box. 因此,如果组合框中有3个项目,则组合框中的每个项目都应具有3个不同的字符串数组。

4) When the user comes back to the form, set the selected item as : 4)当用户返回到表单时,将所选项目设置为:

combox.setSelectedIndex(index of that item here)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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