compile 'com.facebook.litho:litho-core:0.3.1'
compile 'com.facebook.litho:litho-widget:0.3.1'
provided 'com.facebook.litho:litho-annotations:0.3.1'
annotationProcessor 'com.facebook.litho:litho-processor:0.3.1'
I want to create a more complexe layout that a simple text to pass on LithoView.create() function. I tried to create a layout by using the Column ComponentLayout but it does not work because the method LithoView.create() accept only Component and not ComponentLayout.
Here is an example:
final RecyclerBinder recyclerBinder = new RecyclerBinder(componentContext,
new LinearLayoutInfo(this, OrientationHelper.VERTICAL, false)
);
final Component recycler = Recycler.create(componentContext)
.binder(recyclerBinder)
.build();
ComponentLayout cl = Column.create(componentContext)
.child(Button.create(componentContext)
.text("validate")
.listener(new ButtonSpec.ButtonClickListener() {
@Override
public void onClick() {
Toast.makeText(componentContext, "click", Toast.LENGTH_SHORT).show();
}
}))
.child(recycler)
.build();
setContentView(LithoView.create(this, cl));
How do I set Column or any other LayoutComponentas the root of my LithoView?
@Martin-Hogge this is a limitation of the framework that we plan to fix in the future, but for now you'd have to create a new @LayoutSpec-annotated class and use the generated component as the root of your LithoView. Hope that helps!
Any updates on this? When do you plan to release?
This now works as you hope. Column.create(c) returns a Component, so you can pass that to LithoView.create
I don't think there is a full release with that change in, but if you use a snapshot release then you will get that behaviour.
Most helpful comment
@Martin-Hogge this is a limitation of the framework that we plan to fix in the future, but for now you'd have to create a new @LayoutSpec-annotated class and use the generated component as the root of your LithoView. Hope that helps!