• Register
1 vote
279 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.9k points

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 :

36.1k points

Related questions

0 votes
1 answer 609 views
609 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 197 views
197 views
Problem : I am trying to learn Android programming also I am trying to develop a very basic weather app. My code works perfectly if I try to enter any valid city name. But I want to use the toast and it shows me the error and also to the ... .nextCleanInternal(JSONTokener.java:116) at org.json.JSONTokener.nextValue(JSONTokener.java:94) at org.json.JSONObject. How can I fix the above error?
asked Feb 14 mphil 2.3k points
0 votes
1 answer 882 views
882 views
Problem : I am learning Android Studio. I am trying to add implemntation 'com.google.android.material:material:1.0.0-alpha1' but if I try to build the project then my Android Studio gives below error: Program type already present: android.support.v4.app. ... .support.v4.app.INotificationSideChannel$Stub$Proxy, sources=[Unknown source file], tool name=Optional.of(D8)} How can I fix the above error?
asked Feb 19 mphil 2.3k points