tablelayout - Android TableRow - How to add View dynamically to certain postion? -
I'm dynamically creating TableLayout and I need the tableau, there is a difference in some column position.
For example, I have an image of line 3 and 5 on position, ImageView 1, 2, 4 position is in the next line. I try to use:
table row line 1 = new lockover (this); Row1.addView (new ImageView (this), 2); Row1.addView (new ImageView (this), 4); MTable.addView (ROW1); Table row line 2 = new talc (this); Row2.addView (new ImageView (this), 0); Row2.addView (New ImageView (this), 1); Row2.addView (New ImageView (this), 3); MTable.addView (line2);
But I found the index upfold exception at runtime.
Error / Android Randomime (771): generated by: java.lang.IndexOutOfBoundsException: index = 2 count = 0
Any suggestions would be appreciated. Thanks.
Actually, the error seems logical enough for the first time to look at your code until you get the table XML Not created and as the number of required rows, when you add a view to index 2, then this index does not exist. Try to replace it with 2, you'll see that it works. If you want to stick to your, then you just have to add other indexes to the empty imageview.
Comments
Post a Comment