Check out example codes for "The specified child already has a parent. You must call removeView() on the child's parent first". It will help you in understanding the concepts better.

Code Example 1

if(tv.getParent() != null) {
    ((ViewGroup)tv.getParent()).removeView(tv); // <- fix
layout.addView(tv); //  <==========  ERROR IN THIS LINE DURING 2ND RUN

Learn ReactJs, React Native from