简体   繁体   English

向现有资源数组添加新值

[英]Add new values to existing resource array

I have a res/values String-array that I would like users to be able to add new elements to via a form.我有一个 res/values 字符串数组,我希望用户能够通过表单向其中添加新元素。 I saw a post from 2011 that asked this question ( How to update arrays in res/values/array.xml by code? ) however, the answer stated that resource arrays are read-only at run time.我看到 2011 年的一篇帖子提出了这个问题( 如何通过代码更新 res/values/array.xml 中的数组? )但是,答案指出资源数组在运行时是只读的。 I was wondering if anything has changed since 2011 that would allow users the ability to update the resource array (add new strings to it).我想知道自 2011 年以来是否发生了任何变化,允许用户更新资源数组(向其中添加新字符串)。

Unfortunately resource values are still immutable.不幸的是,资源值仍然是不可变的。 They are generated when your project is compiled and overriden on every compilation.它们是在您的项目被编译并在每次编译时覆盖时生成的。 There is a corresponding warning here in the documentation: https://developer.android.com/guide/topics/resources/accessing-resources.html文档中这里有相应的警告: https : //developer.android.com/guide/topics/resources/accessing-resources.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM