gpt4 book ai didi

android - 如何在 Android 中将网格子项的绘制方向更改为 Right_To_Left

转载 作者:搜寻专家 更新时间:2023-11-01 07:40:33 25 4
gpt4 key购买 nike

我正在尝试使用网格,但我需要将插入子项的方向从(从左到右)更改为(从右到左)。有什么办法可以做到这一点,简单的例子会帮助我更多。

提前致谢。

最佳答案

这是我写的。我想解决你的问题

   /** 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;

}

关于android - 如何在 Android 中将网格子项的绘制方向更改为 Right_To_Left,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4353703/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com