문제

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