
Untitled
By: a guest on
Aug 12th, 2012 | syntax:
None | size: 1.33 KB | hits: 11 | expires: Never
Pass an Array of audio files to ArrayList
int[] lessonClips = { R.raw.button_a, R.raw.button_2, R.raw.button_3,
R.raw.button_4, R.raw.button_5, R.raw.button_6 };
public ArrayList<HashMap<String, String>> getPlayList(){
File home = new File(new String("/sdcard/audio"));
if (home.listFiles(new FileExtensionFilter()).length > 0) {
for (File file : home.listFiles(new FileExtensionFilter())) {
HashMap<String, String> song = new HashMap<String, String>();
song.put("songTitle", file.getName().substring(0, (file.getName().length() - 4)));
song.put("songPath", file.getPath());
// Adding each song to SongList
songsList.add(song);
}
}
// return songs list array
return songsList;
}
public class Song {
String title;
String path;
int resource; //R.raw.*
//setters and getters
}
ArrayList<String> songList;
ArrayList<Song> songList; //10s' suggestion.
for(int x = 0; x < lessonClips.length; x++)
{
songList.add(getApplicationContext().getResources().
getResourceEntryName(lessonClips[x]);
}