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

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -