开发者

Storing media resources in xml file

开发者 https://www.devze.com 2023-04-05 10:46 出处:网络
I am working with a application where I want to play a mp3-file. Depending on a user choice (this part is finished) a specific file shall be played.

I am working with a application where I want to play a mp3-file. Depending on a user choice (this part is finished) a specific file shall be played. My intention is to use a specific Activity to play the file. To do this I need to read the identifier of the m开发者_C百科p3 file from e.g. string.xml. Is it possible to store the resource ID in an xml file? If it is the case, how? Or is there perhaps other solutions.

/Christer New in Android development.


This is now soleved: The file name (without ext) is stored in a string-array and then use a code like this:

                Resources res = getResources();
                files=res.getStringArray(R.array.mp3_array);
                file=files[position];
                id=res.getIdentifier( file , "raw" , "packagename" );
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号