Getting selected element from ListView
Say with list view like this:
ListView<String> listView =new ListView<String>();
Getting selected element from ListView:
listView.getSelectionModel().getSelectedItem();
Tracking (Listening) the changes in list view selection:
listView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<String>() {
@Override
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
System.out.println("ListView selection changed from oldValue = "
+ oldValue + " to newValue = " + newValue);
}
});