7

I have an android application that needs to display strings found under the resources, but there can be multiple strings.xml files, i.e. strings1.xml, strings2.xml and so third. The string key can reside in different stringsN.xml files, now if a key is found in lets say strings1.xml it should be displayed without looking into the other string files with the same key.

Is it possible in android? I have done this thing in my .Net application but seems not doable in android. Infact, android gives the compilation error when I enter values against duplicate keys in multiple strings.xml files.

EDIT

The reason for doing this is, there are different clients running my application. Lets assume for clientA I added the key "company" with the value "ABC" and in my default strings.xml file there is already a default company name with the same key "company" but with the defualt value "Default Company". Now, if clientA opens my application the company name should be "ABC" and "Default Company" for clients otherthan clientA.

4

1 回答 1

2

不,这在 Android 上是不可能的。

您只能在不同的文件夹 ( values-qualifier) 中有重复的资源名称。即使那样,字符串也不会重复。它们已准备好进行本地化,一次只会加载一个。

如果您告诉我们为什么需要这个,我们或许可以提出更好的解决方案。

于 2013-04-10T13:08:56.770 回答