【发布时间】:2021-08-23 17:00:17
【问题描述】:
我在 raw 文件夹中有一些 mp3 文件,我将它们作为资源路径(例如 R.raw.music)存储在 Room 数据库中,并且我本地化了 raw 文件夹。我想从选定的语言中获取本地化的 mp3 文件。这是我获得本地化字符串的方法
fun getLocaleStringResource(requestedLocale:Locale,resId:Int,context: Context) :String{
val result:String
val config = Configuration(context.resources.configuration)
config.setLocale(requestedLocale)
result= context.createConfigurationContext(config).getText(resId).toString()
return result}
【问题讨论】:
标签: android android-studio kotlin android-mediaplayer android-resources