ファイルとディレクトリのリストがありますが、リストに編成がありません。最初にアルファベット順にリストされたディレクトリ、次にファイルでソートしたいと思います。どうすればこれを達成できますか?
private void fill(File[] files) {
this.directoryEntries.clear();
// and the ".." == 'Up one level'
if(this.currentDirectory.getParent() != null && !this.currentDirectory.equals("/sd card"))
this.directoryEntries.add(new IconifiedText(
getString(R.string.up_one_level),
getResources().getDrawable(R.drawable.uponelevel)));
Drawable currentIcon = null;
for (File current_File : files){
if (current_File.isDirectory()) {
currentIcon = getResources().getDrawable(R.drawable.folder);
}else{
String fileName = current_File.getName();
/* Determine the Icon to be used,
* depending on the FileEndings defined in:
* res/values/fileendings.xml. */
if(checkEndsWithInStringArray(fileName, getResources().
getStringArray(R.array.fileEndingJs))){
currentIcon = getResources().getDrawable(R.drawable.mimejs);
}else if(checkEndsWithInStringArray(fileName, getResources().
getStringArray(R.array.fileEndingHTML))){
currentIcon = getResources().getDrawable(R.drawable.mimehtml);
}else if(checkEndsWithInStringArray(fileName, getResources().
getStringArray(R.array.fileEndingCSS))){
currentIcon = getResources().getDrawable(R.drawable.mimecss);
}else if(checkEndsWithInStringArray(fileName, getResources().
getStringArray(R.array.fileEndingXML))){
currentIcon = getResources().getDrawable(R.drawable.mimexml);
}else if(checkEndsWithInStringArray(fileName, getResources().
getStringArray(R.array.fileEndingPhp))){
currentIcon = getResources().getDrawable(R.drawable.mimephp);
}else{
currentIcon = getResources().getDrawable(R.drawable.mimetxt);
}
}
switch (this.displayMode) {
case ABSOLUTE:
/* On absolute Mode, we show the full path */
this.directoryEntries.add(new IconifiedText(current_File
.getPath(), currentIcon));
break;
case RELATIVE:
/* On relative Mode, we have to cut the
* current-path at the beginning */
int currentPathStringLenght = this.currentDirectory.getAbsolutePath().length();
this.directoryEntries.add(new IconifiedText(
current_File.getAbsolutePath().
substring(currentPathStringLenght),
currentIcon));
break;
}
}
Collections.sort(this.directoryEntries);
itla.setListItems(this.directoryEntries);
this.setListAdapter(itla);
}