Resizing dynamic TableLayout in android

Home / Uncategorized / Resizing dynamic TableLayout in android

Question:
I have created a dynamic TableLayout in Android. The problem is, there is an unnecessary gap in the column. I’d like to remove it, I’ve been changing the code a few times but the results are astonishing. Here is the best that I can get at the moment.

TableLayout Image

As you can see, there is a gap in the header and also in the row if the row consisting 2+ lines. I want to make the first column (which is Items) have the longest width while the other column just wraps the content with the header.

here is the XML



And here is the code to make dynamic row
private void init() {

// Array for item
String[] valuesItem = new String[] {
"Room asd",
"Room qwewq",
"Room kadskadskl",
"Room oeqwoeqwo",
"Room uuawuwauaw" };

final ArrayList listItem = new ArrayList();
for (int i = 0; i < valuesItem.length; ++i) { listItem.add(valuesItem[i]); } // Array for quantity String[] valuesQuantity = new String[] { "1", "1", "2", "1", "2" }; final ArrayList listQuantity = new ArrayList();
for (int i = 0; i < valuesQuantity.length; ++i) { listQuantity.add(valuesQuantity[i]); } // Array for price String[] valuesPrice = new String[] { "10", "10", "20", "50", "30" }; final ArrayList listPrice = new ArrayList();
for (int i = 0; i < valuesPrice.length; ++i) { listPrice.add(valuesPrice[i]); } // Array for total String[] valuesTotal = new String[] { "10", "10", "40", "50", "60" }; final ArrayList listTotal = new ArrayList();
for (int i = 0; i < valuesTotal.length; ++i) { listTotal.add(valuesTotal[i]); } for (int i = 0; i Answer:

Read more

Leave a Reply

Your email address will not be published. Required fields are marked *