這樣做, 我只是添加邏輯。你必須做麪糊的方式。 一切順利。
public void selectRow(int selectedItemPos)
{
int TotlaItemInGrid = 17;
int lastpos = TotlaItemInGrid-1;
//0 1 2
//3 4 5
//6 7 8
//9 10 11
//12 13 14
//15 16
// case 1 if user select first row
// in this condition position 0,1,2 will fix
if(selectedItemPos == 0 || selectedItemPos==1 || selectedItemPos==2)
{
for(int pos =selectedItemPos ; pos<=lastpos; (pos+2))
{
// do selection
// if you select 0 then here you will get result like 0,3,6,9...
// if you select 0 then here you will get result like 1,4,7,10...
// if you select 0 then here you will get result like 2,5,8,11..,
}
}
// case 2 if user select last row
//
else if(selectedItemPos == lastpos || selectedItemPos==(lastpos-1) || selectedItemPos==(lastpos-2))
{
for(int pos =selectedItemPos ; pos>=0; (pos-2))
{
// do selection
}
}
// case 3 in between first and last row
else
{
for(int pos =selectedItemPos ; pos>=0;(pos-2))
{
// do selection
}
for(int pos =selectedItemPos ; pos<=lastpos; (pos+2))
{
// do selection
}
}
}
如果我選擇第三個位置(第一行的最後一項)?如果我使用p + 2,我將更改行。你能給我一個代碼示例嗎? – Apollon