从组合框中删除项目 lwuit?

发布于 2024-12-15 18:05:11 字数 80 浏览 1 评论 0原文

如何从 LWUIT 中的组合框中删除所有项目或单个项目?

是否有像 removeall() 这样的函数?

How to remove all items or a single item from a combo box in LWUIT ?

Is there any functions like removeall() ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

雪化雨蝶 2024-12-22 18:05:11

使用 getModel().removeItem(index) 并从 ComboBox 中删除该项目。请参阅示例代码,

ComboBox c = new ComboBox(vector); // you can use ListModel or String[] instead of vector

// for remove single item in combobox
c.getModel().removeItem(index); // pass the removable index number

如果要删除所有项目,则需要在 combobox.setModel(model) 上设置空的 ListModel 或传递空的 VectorComboBox 构造函数上。

Use getModel().removeItem(index) and remove the item's from ComboBox. See the sample code,

ComboBox c = new ComboBox(vector); // you can use ListModel or String[] instead of vector

// for remove single item in combobox
c.getModel().removeItem(index); // pass the removable index number

If you want to remove all item means set the empty ListModel on combobox.setModel(model) or pass the empty Vector on ComboBox constructor.

╰ゝ天使的微笑 2024-12-22 18:05:11

删除lwuit中组合框中的所有项目,示例代码如下:

ListModel listModel=dayCombo.getModel();

int size_of_previous_day=listModel.getSize();
for(int i=0;i<size_of_previous_day;i++)
    listModel.removeItem(0);
dayCombo.setModel(listModel);

Deleting the all the items from combobox in lwuit,sample code given below:

ListModel listModel=dayCombo.getModel();

int size_of_previous_day=listModel.getSize();
for(int i=0;i<size_of_previous_day;i++)
    listModel.removeItem(0);
dayCombo.setModel(listModel);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文