The specified child already has a parent. You must call removeView() on the child's parent first (Android)
The error message says what You should do.
// TEXTVIEW
if(tv.getParent() != null) {
((ViewGroup)tv.getParent()).removeView(tv); // <- fix
}
layout.addView(tv); // <========== ERROR IN THIS LINE DURING 2ND RUN
// EDITTEXT
Kotlin : The specified child already has a parent. You must call removeView() on the child's parent first
You're trying to add the LinearLayout
with the ID root_layout
as its own child here:
layout.addView(layout)
Perhaps you meant to add your newly inflated View
as its child?
layout.addView(view)
The specified child already has a parent. You must call removeView() on the child's parent first. Facing this issue
Seems like this was reported and according to the comment in there, this should be fixed for preview 11+: github.com/dotnet/maui/issues/3511 Which VS2022 have you installed?
Installing Visual Studio 2022 v17.1 Preview 2 should give you .NET MAUI Preview 11 which should resolve the issue.
Related Topics
Youtube Video Not Playing in Webview
How to Switch Automatically Between Viewpager Pages
Bitmap Too Large to Be Uploaded into a Texture
Which View Should Be Used for New Material Design Bottom Navigation
Getting Null Device Id While Registering to Gcm
Custom Global Application Class Breaks with "Android.App.Application Cannot Be Cast To"
Android Screen Sizes in Pixels for Ldpi, Mdpi, Hpdi
How to Change App Name Per Gradle Build Type
Outdated Kotlin Runtime Warning in Android Studio
How to Break Styled Text into Pages in Android
How to Setup Appium in Ubuntu for Android
Compatiblity of Material Design to Versions Below Android 5.0
Android Sharedpreferences Limitations
How to Display Map (Google) on a Phonegap Android Application
Failure [Install_Failed_Update_Incompatible] Even If App Appears to Not Be Installed