carlw
10/22/2016, 1:01 PMedvin
10/22/2016, 1:01 PMedvin
10/22/2016, 1:02 PMedvin
10/22/2016, 1:04 PMcarlw
10/22/2016, 1:05 PMedvin
10/22/2016, 1:06 PMvoddan
10/22/2016, 1:06 PMvoddan
10/22/2016, 1:07 PMitem
is always null
edvin
10/22/2016, 1:07 PMvoddan
10/22/2016, 1:07 PMhbox
latervoddan
10/22/2016, 1:08 PMcarlw
10/22/2016, 1:08 PMedvin
10/22/2016, 1:10 PMListCellFragment
is contained in a ListCell, and a ListCell is reused to display different items as you scroll through your list. For that reason, the itemProperty
and corresponding "getter" in item
is changed as the fragment is reused to display different items as well. When you initialize it, there is no item bound to it at all. That's the reason the item value is null in the constructor. For this use case I think it's much easier to use cellCache
which gives you the item right away. To use cellCache
you must make sure that you have a valid equals/hashCode
impl in the Word
class.edvin
10/22/2016, 1:10 PMcellFormat { label(it) }
and you're doneedvin
10/22/2016, 1:11 PMedvin
10/22/2016, 1:11 PMvoddan
10/22/2016, 1:12 PMedvin
10/22/2016, 1:12 PMvoddan
10/22/2016, 1:12 PMvoddan
10/22/2016, 1:13 PMedvin
10/22/2016, 1:13 PMcellFormat
which is called much more frequently than cellCache
but does not need an equals/hashCode
implementation.edvin
10/22/2016, 1:13 PMcellCache
or possibly ListCellFragment with a view model so you can have nice tidy bindings.edvin
10/22/2016, 1:14 PMvoddan
10/22/2016, 1:14 PMclass Word(val value: Int)
voddan
10/22/2016, 1:14 PMedvin
10/22/2016, 1:15 PMvoddan
10/22/2016, 1:15 PMedvin
10/22/2016, 1:15 PMcellCache
🙂voddan
10/22/2016, 1:16 PM