how to find out the coordinates of an item in a gridview Android -
i find out how find coordinates (x,y) of gridview user clicks on based on returned position?
0 1 2 3 4 5 6 7 8
if use 4 selected item can work out on row 1
4 / columnlength(3) = 1.3 etc
but whats best way calclate column? or there built in methods can take advantage of?
first need define few things
int numberofcolumns;//should able view int numberofrows = math.ceil(items.count / numberofcolumns);
then can figure out position
int row = math.ceil((position + 1) / numberofcolumns); int column = (row * numberofcolumns) - position;
that should it
Comments
Post a Comment