• Register
1 vote
935 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 3 views
3 views
Problem: How to change fontFamily of TextView in Android?
asked Apr 16 sumaiya simi 43.9k points
0 votes
1 answer 7 views
7 views
Problem: Help me, just click "add answer" and request to help me on this situation.
asked Apr 4 niyatiry 3.9k points
0 votes
1 answer 2 views
2 views
Problem: I am using the Gboard from Google in my app and when i input a GIF from the keyboard app to my EditText it then shows a toast."The text field does not support GIF insertion from the keyboard"I have search about this a thousand times and can't find out a result.Any help would be appreciated.
asked 2 days ago sumaiya simi 43.9k points
0 votes
1 answer 1 view
1 view
Problem: I am using the Gboard from Google in my app and when i input a GIF from the keyboard app to my EditText it then shows a toast "The text field does not support GIF insertion from the keyboard" I have search about this a thousand times and can't find out a result Any help would be appreciated.
asked 2 days ago anika11 32k points
0 votes
1 answer 4 views
4 views
Problem: I am using the Gboard from Google in my app and when i input a GIF from the keyboard app to my EditText it then shows a toast "The text field does not support GIF insertion from the keyboard" I have search about this a thousand times and can't find out a result Any help would be appreciated.
asked 2 days ago Yeamin 21.4k points
1 vote
1 answer 4 views
4 views
Problem : Please give me any advise > How do I pass the string from an edit text in one activity to another activity on android?
asked 3 days ago Abik Dey 4k points
0 votes
1 answer 18 views
18 views
Problem: I am using the Gboard from Google in my app and when I input a GIF from the keyboard app to my EditText it then shows a toast "The text field does not support GIF insertion from the keyboard" Any help would be appreciated.
asked Mar 19 ummesalma 29.2k points
0 votes
1 answer 22 views
22 views
Problem : Error : "you must not call settag() on a view glide is targeting "
asked Feb 26 Sabbir Hossain 14.6k points