I'm working on basic To Do list. Problem is when I change to another scene and return to the original one where the ListViews are, they are all empty. Also when I edit an item and go to the "Search" scene, the edit didn't save.
Adding stuff seems to be working, so is using the Search bar in a different scene. Just the todoList ListView doesnt seem to be saving items when refreshing.
Is there a problem in my add method? Or is there another issue?
@FXML
private TextField nameField;
@FXML
private ChoiceBox<String> choiceBox;
@FXML
public ListView<String> todoList;
void addItem(MouseEvent event) {
Item item = new Item();
String status = choiceBox.getValue();
if (status.equals("New feature")) {
item.description = Item.Description.NewFeature;
} else if (status.equals("Edit feature")) {
item.description = Item.Description.EditFeature;
} else {
item.description = Item.Description.Bug;
}
item.name = nameField.getText();
todoList.getItems().add(item.name + " - " + item.description);
itemArray.add(item.name + " - " + item.description);
nameField.clear();
StringConverter<String> converter = new DefaultStringConverter();
todoList.setEditable(true);
todoList.setCellFactory(param -> new TextFieldListCell<>(converter));
inprogList.setEditable(true);
inprogList.setCellFactory(param -> new TextFieldListCell<>(converter));
doneList.setEditable(true);
doneList.setCellFactory(param -> new TextFieldListCell<>(converter));
Then when I switch scenes to my "Search" page, all the added items show. Problem is when I switch back to my original scene, the listviews are empty again.