android - ViewGroup.java AddViewInner issue -


i keep getting following errors, it's same error keeps occuring on different lines

fatal exception: java.lang.illegalstateexception: specified child has parent. must call removeview() on child's parent first. @ android.view.viewgroup.addviewinner(viewgroup.java:3883)

fatal exception: java.lang.illegalstateexception: specified child has parent. must call removeview() on child's parent first. @ android.view.viewgroup.addviewinner(viewgroup.java:4312)

fatal exception: java.lang.illegalstateexception: specified child has parent. must call removeview() on child's parent first. @ android.view.viewgroup.addviewinner(viewgroup.java:4310)

things have tried :-

  • while adding fragment add code in oncreateview

    ((viewgroup) view.getparent()).removeview(view); view = inflater.inflate(r.layout.create_carpool_layout, container, false); return view;

    and inflate view

  • while inflating layouts / views in adapter make sure view removed parent view

i not sure causing problem

try double checking how inflating view.

there 2 possible ways:

  1. passing parent inflater:

    layoutinflater.from(context).inflate(r.layout.layout, this, true); 
  2. keep view without parent:

    layoutinflater.from(context).inflate(r.layout.layout, null); 

when using first method, cannot call addview() view parameter.
using second way, view not pinned parent, therefore can invoke addview()


Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -