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. Dynatree如何更改兒童網址ajax
- 2. 與方形兒童的網格佈局
- 3. 更改兒童類
- 4. 如何更改所有兒童的JavaFX
- 5. 更改HTML中的兒童
- 6. 如何在方向更改時管理標籤活動內的兒童活動?
- 7. 定製兒童
- 8. 重繪兒童的JPanel
- 9. Gallery/AdapterView兒童可繪製狀態
- 10. Android的 - 改變的佈局兒童onMeasure
- 11. 控制兒童控制風格
- 12. 如何更改InkCanvas的繪製方式?
- 13. MATLAB:更改圖形高度會導致兒童uicontrols向相應方向移動
- 14. 當可見性改變時,mdi兒童形式繪製緩慢
- 15. 從兒童更改窗口父網址不改變完成url
- 16. XNA - 如何更改繪製字符串列表的方向
- 17. JQuery的:更改所有兒童元素
- 18. 的onmouseover兒童更改父顏色
- 19. 兒童名稱的CSS更改高度
- 20. 更改兒童的特異性
- 21. d3:繪製一次兒童,但每次更新
- 22. SL4:在網格中覆蓋兒童
- 23. C#網格按鈕兒童測試
- 24. 與Kendo Ui兒童網格互動
- 25. 分層數據網格兒童
- 26. 如何通過paintEvent在兒童視圖中繪製圖像
- 27. Android兒童片段
- 28. 點擊兒童Android
- 29. WPF - 如何更改父母的鼠標懸停的兒童風格
- 30. 如何對兒童
我會檢查它..感謝 – 2012-05-11 09:54:33