Conflicting Android error messages: The specified child already has a parent. You must call removeView() on the child's parent first
问题 Originally I got this error: The specified child already has a parent. You must call removeView() on the child's parent first at customSection.addView(customLayout); So I added ((LinearLayout)customLayout.getParent()).removeView(customLayout); and now get java.lang.NullPointerException So if the child has a parent, and I must first remove the child from the parent, why does getParent() return null? I have an abstract fragment that allows derived classes to supply a custom layout for the list