georgiy.shur
06/23/2021, 10:33 AMComposeView using interop. I have a custom view which extends AbstractComposeView , then I’m trying to add this view programmatically with listItem.addView(myComposeView) inside the onBindViewHolder method of RV adapter (inside one of the items). It crashes with java.lang.IllegalStateException: ViewTreeLifecycleOwner not found from id/listItem .
I’ve tried to debug it and I found that it tries to recursively find a parent with android.R.id.content , but the problem with RecyclerView is that sometimes it returns null for its children’ getParent() , because they’re not yet attached to viewholder. So the parent is null means it doesn’t have ViewTreeLifecycleOwner . Is it a bug or expected behavior? Should I do it differently? Is there a way to work around it?Adam Powell
06/23/2021, 1:26 PM