Android From gridview layout index convert into row and column

被刻印的时光 ゝ 提交于 2019-12-05 22:02:23
// x : horizontal position in range [0; columns-1]
// y : vertical position in range [0; rows-1]

int x = index % columns;
int y = index / columns;
int column = x + 1;
int row = y + 1;

to reverse:

int index = x + y * columns;

or

int index = (column - 1) + (row - 1) * columns;
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!