Skip to content Skip to sidebar Skip to footer

Android: Adding Multiple Views To A Linear Layout Dynamically

I checked the solution here: Adding multiple views of the same type Its given that, create a new View everytime you add it instead of changing only 1 view. But i am doing this: for

Solution 1:

usually I use this

privatevoidrenewDetail(){
        llDetail.removeAllViews();
        for (int i = 0; i < 10; i++) {
            llDetail.addView(new ChildDetailNotePieDiagram(context, "Name", 1000, 10));
        }
    }

the logic is first I clear all view from the parent layout and then add view to the parent layout.

where llDetail is a linear layout and I create a linear layout class ChildDetailNotePieDiagram and add it to the linear layout so basically it's a different solution from what you use now but I think you can try my solution if you want :) feel free to ask any question about this in the comment

Post a Comment for "Android: Adding Multiple Views To A Linear Layout Dynamically"