I'm using a ListView
in a JavaFX application. The items in the list require more than just a string to display them so I made a custom implementation of ListCell<T>
, where T
is the class of the objects I'm displaying. In this custom class, I create a BorderPane
in the constructor and override updateItem(T item, boolean empty)
. The idea was that when updateItem
is called, I set the graphic of the cell to be the BorderPane while change some properties of Label
s inside of it. However, I noticed updateItem
is not called once (e.g. when a cell is recycled through scrolling or a new item is added), but it is called all the time, e.g. when the focus changes from one cell to another (even without scrolling), or when the scene is resized, or when a button inside the borderpane is pressed, ...
I need to have a ListView
with custom ListCell
s. I want to receive one callback when a cell is reused, passing the new item to be rendered as a parameter. Then I want to use that item as a model to construct a view-controller pair of which I take the view and use it as the graphic
of the cell. Buttons and other controls inside this view should work. Is this possible in JavaFX?
Linked problem:
- Weird recycle of cells in ListView - JavaFX
- javafx listview with button in each cell (I've done this btw and the button callback works, but there are still way too many callbacks to
updateItem
)