2015-01-08 13 views

回答

3

GridPagerAdapter可以覆蓋getCurrentColumnForRow()

返回列垂直導航到指定行的時候到達。

默認實現返回0

因此你可以寫這樣的:

public int getCurrentColumnForRow (int row, int currentColumn) { 
    return currentColumn; 
} 

如果所有的行具有相同數量的列或某事的略微如果他們不復雜't:

public int getCurrentColumnForRow (int row, int currentColumn) { 
    return Math.min(getColumnCount(row)-1, currentColumn); 
} 
+0

當我重寫getCurrentColumnForRow(int row,int currentColumn)時,應用程序崩潰時,我滑到第三欄(甚至沒有機會上下移動)。如果我不重寫getCurrentColumnFor,它工作正常。 – Kei

+0

並且崩潰是由IndexOutOfBound引起的:Length = 2;索引= 2;頁面大小是3 x 3. – Kei

+0

啊,是的,它應該是'getColumnCount(row)-1'而不是'getColumnCount(row)'。我已經更新了我的答案。 – ianhanniballake