Android 具有自定义对象重新排序的数组列表
我有一个Android 具有自定义对象重新排序的数组列表,android,arraylist,Android,Arraylist,我有一个ArrayList在媒体项中有一个Boolean字段名为isdownload 我想要一个循环,它可以按isdownload字段从true到false对项目进行排序 试试下面的内容 int ff = 0; // First false index CustomObject pf = list.get(0); // photo with false for (int i = 0; i < list.size(); i++) { CustomObject p = lis
ArrayList
在媒体项中有一个Boolean
字段名为isdownload
我想要一个循环,它可以按isdownload字段从true到false对项目进行排序 试试下面的内容
int ff = 0; // First false index
CustomObject pf = list.get(0); // photo with false
for (int i = 0; i < list.size(); i++)
{
CustomObject p = list.get(i);
if (p. IsDownloaded())
{
// Replace it with the current photo with false
list.set(i, pf);
// Put the selected photo in place of the first false photo (and move this index)
list.set(ff++, p);
// Next photo is the next to swap (might also advance ff up to the next unselected photo)
pf = list.get(ff);
}
}
for (CustomObject p : list) {
println(p.selected + "," + p.index);
}
int ff=0;//第一假索引
CustomObject pf=list.get(0);//假照片
对于(int i=0;i
在做任何事情之前,请先阅读:谢谢,它成功了。