I have a List of TableLayout’s that are each generated from data in my database. I need to loop through this list and add each TableLayout to my LinearLayout.
Below is the code I currently have, however it looks like each time the table is added, it is replacing the last one so the end result is the app displaying only the last table in the list (as far as I can tell)
container = (LinearLayout) findViewById(R.id.container);
for (int i = 0; i < listOfTables.size(); i++) {
container.addView(listOfTables.get(i), i);
}
Any ideas?
Max.
You need to play with the XML height and width attributes, in all likelihood.
Try changing the
layout-heightandlayout-widthattributes for the table layouts and the linear layout towrap_contentand see what that does 🙂You might also try changing the code so it doesn’t have the 2nd argument. It should add the layouts linearly.
Hope this helped!