The problem is because the views are already added to the layout in the XML
file. Then you findViewById
(find them) and try to add them to the layout again. That is why the app crashes complaining that, view already has a parent and you can't add it again.