• Register
1 vote
638 views

Problem :

When I call a blank layout and afterwards call my layout it gives me the following error:
the specified child already has a parent. you must call removeview() on the child's parent first.
6 5 3
6,930 points

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

In my case it comes when i want to add view by parent to other view

View root = inflater.inflate(R.layout.single, null);
LinearLayout lyt = root.findViewById(R.id.lytRoot);
lytAll.addView(lyt);  //it crashes

So to avoid the crash one must add parent view like this

View root = inflater.inflate(R.layout.single, null);
LinearLayout lyt = root.findViewById(R.id.lytRoot);
lytAll.addView(root); //it works fine
I followed above steps and my issue got resolved.

Further Readings :

9 7 4
38,600 points

Related questions

0 votes
1 answer 4 views
4 views
Problem : Error : "you must not call settag() on a view glide is targeting "
asked 3 days ago Shovo210 3.1k points
0 votes
1 answer 1.6K views
1.6K views
Problem : I am new to java, I am trying to display this feed in Custom list view but when I am trying to do so I am getting the following error "Attempted to finish an input event but the input event receiver has already been ... 0xa50c8260, error=EGL_SUCCESS hilz.myapplication W/InputEventReceiver: Attempted to finish an input event but the input event receiver has already been disposed.
asked Nov 25, 2019 alecxe 7.5k points
0 votes
1 answer 6 views
6 views
Problem: this activity already has an action bar supplied by the window decor and Trying to move over my stuff to use Toolbar instead of action bar but I keep getting an error.
asked Feb 13 Shovo210 3.1k points
0 votes
1 answer 9 views
9 views
problem java.lang.illegalstateexception: already managing a googleapiclient with id 0
asked Feb 9 charles mathews 3.8k points
0 votes
1 answer 14 views
14 views
Problem: make sure to call firebaseapp.initializeapp(context) first.
asked Feb 17 Dan phillip 1.9k points
0 votes
1 answer 2 views
2 views
Problem: Why I got the error : the activity must be exported or contain an intent-filter. Can some one please help fix this, Help I am new in this language. Any Ideas on what I need to fix this? Thanks in advance.
asked 1 day ago James Smith 8.3k points