Adding child views to Relative Layout

后端 未结 2 1755
野的像风
野的像风 2021-01-25 04:43

Though I have been through many questions regarding relative layout and adding child view programatically, I am unable to resolve this issue

for (int i=0; i

        
2条回答
  •  清酒与你
    2021-01-25 04:57

    You're adding the same View objects in a loop over and over. The first time the loop runs the two Views are added and they now have a parent. They cant be added again.

    You'll need to instantiate new instances of those views in every iteration for this to work.

提交回复
热议问题