2
A
回答
3
我寫了這一點。我認爲解決您的問題
/** Returns inverted list by step that take. for example if our list is {1, 2, 3, 4, 5, 6,
* 7 ,8 ,9} and step is 3 inverted list is this: {3, 2, 1, 6, 5, 4, 9, 8, 7}
*/
public static <E> ArrayList<E> invert(List<E> source, int step){
List<E> inverted = new ArrayList<E>();
for(int i = 0; i < source.size(); i++){
if((i + 1) % step == 0){
for(int j = i, count = 0; count < step; j--, count++){
inverted.add(source.get(j));
}
}
}
//
// When (source.size() % step) is not 0 acts.this is for last of list. add last part
// of the source that wasn't add.
//
int remainder = source.size() % step;
if((remainder) != 0){
for (int j = source.size() - 1, count = 0; count < (remainder); j--, count++) {
inverted.add(source.get(j));
}
}
return (ArrayList<E>) inverted;
}
1
我想唯一的方法是創建一個自定義gridview,覆蓋onLayout()方法。 看一看here。
或者你可以反轉列表適配器中每一行的項目?像一個三列格,而不是
[1 2 3][4 5 6][7 8] -->
[3 2 1][6 5 4][null 8 7].
,(我承認我從來沒有使用過的GridView)
1
我臉上有同樣的問題,但最後用復位陣列 解決這裏只更改u [R column no = 3
ArrayList<String> tb_ith_sections_list = new ArrayList<String>;
tb_ith_sections_list = dbhelper.getArrayList();
int sectionCount = tb_ith_sections_list.size();
if(sectionCount > 0){
int rowCount =sectionCount/4;
int colCount ;
if(sectionCount > 4){
colCount=4;
}else{
colCount = sectionCount;
}
if(colCount>sectionCount){
colCount=sectionCount;
}
int k=colCount;
int m=0;
for(int j=0;j<rowCount;j++){
m=(j*colCount);
k=m+colCount;
if(k>sectionCount){
k=(sectionCount-(j*colCount));
}
for(int i=m;i<k;i++){
TB_IVN_SECTIONS tb_Temp=new TB_IVN_SECTIONS();
TB_IVN_SECTIONS tb_ithFirst=tb_ith_sections_list.get(i);
TB_IVN_SECTIONS tb_ithSecond= tb_ith_sections_list.get(k-1);
tb_Temp=tb_ithFirst;
tb_ith_sections_list.set(i, tb_ithSecond);
tb_ith_sections_list.set(k-1,tb_ithFirst);
k--;
}
}
相關問題
- 1. 如何更改所有兒童的JavaFX
- 2. 如何在方向更改時管理標籤活動內的兒童活動?
- 3. Gallery/AdapterView兒童可繪製狀態
- 4. 劍道網格中的兒童項目
- 5. 控制兒童控制風格
- 6. 如何更改InkCanvas的繪製方式?
- 7. 當可見性改變時,mdi兒童形式繪製緩慢
- 8. 從兒童更改窗口父網址不改變完成url
- 9. 的onmouseover兒童更改父顏色
- 10. 更改兒童的特異性
- 11. d3:繪製一次兒童,但每次更新
- 12. SL4:在網格中覆蓋兒童
- 13. 分層數據網格兒童
- 14. C#網格按鈕兒童測試
- 15. 如何通過paintEvent在兒童視圖中繪製圖像
- 16. Android兒童片段
- 17. 從兒童片段更改ViewPager片段
- 18. 如何從兒童
- 19. 如何對兒童
- 20. 更改simpleType元素的限制兒童型
- 21. 如何在兒童擁有網格結構的地方實施Expandable RecyclerView?
- 22. Android方向更改
- 23. 更改方向ANDROID
- 24. 如何從React中的兒童更改父狀態?
- 25. 以編程方式更改ConstraintLayout兒童的邊距和大小
- 26. 如何獲得兒童控制權?
- 27. 如何強制重點兒童形態?
- 28. 如何使用XSL複製兒童
- 29. 如何停止android表格中的方向更改?
- 30. Silverlight 3.0:如何通過x:Name獲取網格兒童?
我會檢查它..感謝 – 2012-05-11 09:54:33