Java – get selected elements from listview
•
Java
I use the results of the database search to modify the listview so that I can use this option to create another database request later
I want to get the field value of this listview What can I do?
I just think I can also add an event on onclick and save it on the properties of the control Is this acceptable?
Solution
Use the list view to say this:
ListView<String> listView =new ListView<String>();
Get selected elements from listview:
listView.getSelectionModel().getSelectedItem();
Track (listen) changes in the 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); } });
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码