1

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

Is there any functions like removeall() ?

Lucifer
  • 29,392
  • 25
  • 90
  • 143
Ganesh
  • 179
  • 10

2 Answers2

5

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.

bharath
  • 14,283
  • 16
  • 57
  • 95
0

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);
SIVAKUMAR.J
  • 4,258
  • 9
  • 45
  • 80