There is no component that does this within the API of Java FX and Google searches gave me nothing so instead, I created my own.
The concept is the same with tables where rows are grouped and row headers give you the option to expand and collapse them.
For List View, I had to make my own CellFactory in order to make this work. I was surprised that I was able to make one. If this was Swing, it might have been different.
This is how my component looks like.
I created an entity class that contains the title and description. Let us call the class, Note. The class has an extra boolean parameter which I use told hold the state of the title if it is expanded or not.
For each entry in the list, I used a vertical box to display the contents. When the title is clicked to expand the description, the VBox will add a child so that it will be shown. If it is collapse, it will be removed.
Simple, right? Cell factories are very handy and flexible in such a way that you can render what you want displayed to the user any way you want to.
If you noticed, there is a method called createArrowPath(). That is a convenience method I made to return an SVGPath object to be used as the arrow icon beside the title header. It takes a parameter height which should be the height of the List View.
If you manage to successfully incorporate GreenDroid into your project, integrate the ActionBar in your activity and see that the title bar and home icon are both blank, no worries. It really is just blank. You need to supply values so they would appear.
I thought at first that for the ActionBar title, the default is the application name but that is not the case since no matter how I tried to tweak the code, they were always blank.
To set the ActionBar‘s title programmatically, do this: