- I load a listview with a list (a).
- In response to a toggle change, I switch the listview content to another list (b). If list (a) is longer than list (b), then the excess items remain displayed in the listview even though it is no longer selectable.
For instance, buyList = {'100532','100533'} and saleList = {'100000'}. If I start with radioBuy selected, the list will show '100532' and '100533'. Switching the toggle from radioBuy to radioSale will cause the list to display '100000' and '100533'. '100533' is not selectable, but it remains visible.
The observable lists themselves have been shown to be the correct size and contain the correct items. It's just that the ListView display shows some old data.
Things I've tried:
1. ticketListView.getItems().clear()
and then rebuilding a new list before the list switch.
2. Using ticketListView.getItems().removeAll(0, ticketListView.getItems().size())
3. Using a loop to remove each item individually.
4. Using ticketListView.refresh()
in combination with all the above.
My toggle ChangeListener:
typeGroup.selectedToggleProperty().addListener(new ChangeListener<Toggle>() {
public void changed(ObservableValue<? extends Toggle> observable, Toggle oldValue, Toggle newValue) {
if (typeGroup.getSelectedToggle().equals(radioBuy))
ticketListView.setItems(buyList);
if (typeGroup.getSelectedToggle().equals(radioTransfer))
ticketListView.setItems(transList);
if (typeGroup.getSelectedToggle().equals(radioSale))
ticketListView.setItems(saleList);
}
});
How do I get my listview to blank itself before it switches content?