
We're going to display list of hero name, image and description on the screen. You can think I am gonna build RecyclerView using Litho. Let's define data class for hero first. data class Hero( val name: String, val description: String, @DrawableRes val image: Int)It's straightforward and let's prepare hero data. package com.mpark.android.marblecharacters class DataLoader { compan..

GroupSection Spec's Lifecylce looks like following: GroupSection Spect has lifecycle in order below: @OnCreateInitialState To set an initial value for a state, you have to write a method annotated with @OnCreateInitialState in your spec. The first parameter must be of type ComponentContext. StateValue and @Prop are allowed. For example, @LayoutSpec object CheckboxSpec { @OnCreateInitialState fun..

Let's implement CharactersComponentSpec to display text list. @OnCreateChildren internal fun onCreateChildren(c: SectionContext): Children { val builder: Children.Builder = Children.create() (1..10).forEach { builder.child( SingleComponentSection.create(c) .key(it.toString()) .component( Text.create(c) .text("Item$it") .textSizeSp(20f) .heightDip(48f) .build() ) .build() ) } return builder.build..