Android TableRow - How to add View dynamically to certain postion?

前端 未结 1 1038
死守一世寂寞
死守一世寂寞 2021-01-13 04:06

I\'m constructing TableLayout dynamically. And I need TableRow has a gap in certain column position.

For example, I need row has ImageView on 3 and 5 position, next

1条回答
  •  礼貌的吻别
    2021-01-13 04:35

    Actually, the error seems quite logical at first glance on your code. Unless you table is created from xml and as the required number of rows, when you add a view at the index 2, this index does not exist. Try replacing this 2 by a 0, you will see that it works. So you just need to add empty ImageView the other indexes if you want to stick to yours.

    0 讨论(0)
提交回复
热议问题