I have GridLayout 7x7, is it possible to change content only of cell (3,4) and I want to do it dynamically. Example: I have 7x7 grid of buttons and want to change button on position (3,4) to TextView.

EDIT: Also, is it possible to set zero padding around child?

Thanks!

有帮助吗?

解决方案

In GridView you cant access elements specific by coordinates (3,4). The elements are numbered like in 2D arrays. So your (3,4) element will have (7*3+4)-1 index. And you can access it by.

ViewGroup gridChild = (ViewGroup) mGridView.getChildAt(24);

EDIT: Set padding to zero.

gridChild.setPadding(0,0,0,0);
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top