is there a way to `include` AnkoComponent into ano...
# anko
d
is there a way to
include
AnkoComponent into another AnkoComponent? like we do it with xml layout
y
deviant: It’s pretty simple:
Copy code
linearLayout {
    addView(SomeOtherComponent().createView(ui))
}
👍 1
d
i'm trying to 'inflate' view as you suggested and catch this error
Copy code
java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
my child view looks like this:
Copy code
override fun createView(ui: AnkoContext<Activity>): View = with(ui) {
        appBarLayout {
            themedToolbar(R.style.ActionBarTheme) {
                bind(viewModel { it::title_ }, this::setTitle)
                popupTheme = R.style.ThemeOverlay_AppCompat_Light
            }
        }
    }
and usage:
Copy code
override fun createView(ui: AnkoContext<Activity>): View = with(ui) {
        coordinatorLayout {
            addView(ToolbarLayout(viewModel.toolbar).createView(ui))
...
@yan i've managed it with the following line:
Copy code
addView(ToolbarLayout(viewModel.toolbar).createView(AnkoContext.Companion.create(ctx,false)))
is it correct? i mean creating of new
AnkoContext