Skip to content
Advertisement

Error while inflating a DialogFragment : The specified child already has a parent. You must call removeView() on the child’s parent first

While trying to inflate a FragmentDialog containing a RecyclerView, I’m having this “The specified child already has a parent. You must call removeView() on the child’s parent first.” error.

Here’s the code from my DialogFragment:

JavaScript

My recycler adapter:

JavaScript

And here’s the stack:

JavaScript

It points the issue to the “dialog.show();” of my DialogFragment. I have to admit that I’m quite lost whit is. I have another DialogFragment that works the same way with no issue.

Advertisement

Answer

I solved my issue, I originaly thought it came from my java code but it was an xml layout issue …

My DialogFrament layout was like that:

JavaScript

and I just needed to use the RecyclerView as a sole element of the layout:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement