LucaMs Expert Licensed User Longtime User Nov 17, 2018 #1 The first attached test project ((SetViewParent test) works as expected: by clicking Button1 it is removed from Panel1 and added to Panel2 (changing its parent) and vice versa by clicking it again. The second project (SetViewParent test 2) is more similar to my real project. It uses some SetLayoutAnimated but what it should do is the same: change the btnMenu's parent. It crashes "saying" that btnMenu is already added to the "destination panel": java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first. I tried adding some Sleep but without success. Attachments SetViewParent test.zip SetViewParent test.zip 9.6 KB · Views: 552 SetViewParent test 2.zip SetViewParent test 2.zip 10.2 KB · Views: 514
The first attached test project ((SetViewParent test) works as expected: by clicking Button1 it is removed from Panel1 and added to Panel2 (changing its parent) and vice versa by clicking it again. The second project (SetViewParent test 2) is more similar to my real project. It uses some SetLayoutAnimated but what it should do is the same: change the btnMenu's parent. It crashes "saying" that btnMenu is already added to the "destination panel": java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first. I tried adding some Sleep but without success.
LucaMs Expert Licensed User Longtime User Nov 17, 2018 #2 Do not pay attention to it; my very stupid mistake (line 79) [Here; now I have to check my real project]... done; it was exactly the same. Upvote 0
Do not pay attention to it; my very stupid mistake (line 79) [Here; now I have to check my real project]... done; it was exactly the same.