I'm tryin开发者_C百科g to create a function that points to a sound file in my R.raw.xxxx folder. I can't figure out how to set the path to the file.
public void setsounds(Button buttonname, int fileId) {
buttonname.setOnLongClickListener(new OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
sound = (R.raw.fileID); //this is where R.raw.fileId should go
return false;
}
});
}
R.raw.fileID
is just an id and more precisely an integer.
To get the actual resource, do something like that from your activity:
InoutStream is = getResources().openRawResource(R.raw.fileID);
精彩评论