I am trying to store resource identifiers for some mp3 files in an array. Here is the code.
private HashMap<String,List<Integer>> listHashMapnum;
private List<String> listhead;
listhead.add("Forty");
listhead.add("Fifty");
ArrayList<Integer> fortysound = new ArrayList<>();
fortysound.add(R.raw.forty);
ArrayList<Integer> fiftysound = new ArrayList<>();
fiftysound.add(R.raw.fifty);
Then I store the array list in a hashmap
listHashMapnum.put(listhead.get(0),fortysound);
listHashMapnum.put(listhead.get(1),fiftysound);
Then I use a function to get the value in the hashmap
public Integer getChild2(int i, int i1) {
return listHashMapnum.get(listheader.get(i)).get(i1);
}
I get the value from the function like this
Integer childsound = (Integer) getChild2(i, i1);
I then use the childsound variable to initialize the mediaplayer
Button bt;
bt = (Button) view.findViewById(R.id.speaker);
final MediaPlayer mp = MediaPlayer.create(context, childsound);
bt.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view){
mp.start();
}
});
But the function returns a int value like "213736282" I found this out while trying to debug. But I don't understand why it does that and what I can do to get my resource identifier from the function. Any help is totally appreciated. Thank you.
Edit: The error was actually in another part of the code so the code above is correct. Thank you