我正在尝试反转位图数组,而不修改源数组。但问题是源数组也正在反转。我做错了什么还是我想以其他方式做?感谢帮助。
private GalleryAdapter galleryAdapter;
private ReverseGalleryAdapter rGalleryAdapter;
public void onCreate(Bundle savedInstanceState) {
galleryAdapter = new GalleryAdapter(this, imageThumbnails, imagePaths,
videoThumbnails, videoPaths);
imagegrid.setAdapter(galleryAdapter);
rGalleryAdapter = new ReverseGalleryAdapter(this, reverseBArray(videoThumbnails), reverseSArray(videoPaths),
reverseBArray(imageThumbnails), reverseSArray(imagePaths));
imagegrid2.setAdapter(rGalleryAdapter);
}
private Bitmap[] reverseBArray(Bitmap[] v){
Bitmap[] bTemp;
bTemp = v;
int len = bTemp.length;
Bitmap temp;
for (int i = 0; i < len/2; i++)
{
temp = bTemp[i];
bTemp[i] = bTemp[len-1 - i];
bTemp[len-1 - i] = temp;
}
return bTemp;
}
private String[] reverseSArray(String[] s){
String[] sTemp;
sTemp =s;
int len = sTemp.length;
String temp;
for (int i = 0; i < len/2; i++)
{
temp = sTemp[i];
sTemp[i] = sTemp[len-1 - i];
sTemp[len-1 - i] = temp;
}
return sTemp;
}