Android - 我如何 select 没有本地化的 strings.xml
Android - How can i select a strings.xml without Localization
是否可以在不更改设备语言的情况下手动 select 一个 strings.xml
文件?
我想让 Button
在两种语言之间切换,但我发现的只是使用 android studio 的内置功能来创建不同的 strings.xml
,这select你的本地化。
If you want to use a different strings.xml
you have to switch localization. This can be done programmatically but is highly not recommended because you will mess with the system.
You can create a different resource XML file that you can put your strings there, give them a unique id and fetch them in the same way (R.id.your_string)
编辑:
You create an XML file that you put into /res/values. This file will declare some strings in the same way the strings.xml does. With ids, values and everything. Then from the code what you do is to conditionally change strings. For example :
if (this){
//get the string from strings.xml here (R.strings.your_string
别的 {
//get the string from your_file.xml here the same way you did above.
{
For more info check the documentation.
是否可以在不更改设备语言的情况下手动 select 一个 strings.xml
文件?
我想让 Button
在两种语言之间切换,但我发现的只是使用 android studio 的内置功能来创建不同的 strings.xml
,这select你的本地化。
If you want to use a different strings.xml
you have to switch localization. This can be done programmatically but is highly not recommended because you will mess with the system.
You can create a different resource XML file that you can put your strings there, give them a unique id and fetch them in the same way (R.id.your_string)
编辑:
You create an XML file that you put into /res/values. This file will declare some strings in the same way the strings.xml does. With ids, values and everything. Then from the code what you do is to conditionally change strings. For example :
if (this){ //get the string from strings.xml here (R.strings.your_string 别的 { //get the string from your_file.xml here the same way you did above. {
For more info check the documentation.