Android Question [SOLVED] Changing view's parent

LucaMs

Expert
Licensed User
Longtime User
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
    9.6 KB · Views: 311
  • SetViewParent test 2.zip
    10.2 KB · Views: 274
Top