| private List<FileProperty> mFileList;mFileList = new ArrayList<FileProperty>(); |
| public class FileProperty { File file; public FileProperty(File file) { super(); this.file = file; } public String getFileName() { return file.getName(); } } |
| public class CompareFile implements Comparator<FileProperty> { String oneFileName, anotherFileName; int result; @Override public int compare(FileProperty object1, FileProperty object2) { // TODO Auto-generated method stub oneFileName = object1.getFileName(); anotherFileName = object2.getFileName(); switch (mSortMode) { case MENU_SORT_BYNAME: result = oneFileName.compareToIgnoreCase(anotherFileName); break; default: break; } return result; } |
| Collections.sort(mFileList, new CompareFile()); |
| Arrays.sort(數組, new CompareFile()); |