编程R.String的变化值String

2023-09-07 09:22:53 作者:没别的

你能不能改变编程方式在Android程序中的R.string的价值观?我需要拉一些API的信息(例如电池状态,电池的百分比,Android操作系统版本),并想将其保存到R.string值。我知道如何阅读:

Can you change the values of a R.string programmatically in an android program? I need to pull some API information (for example battery state, battery percentage, android os version) and would like to save it a R.string value. I know how to read it:

 String helloValue= getResources().getString(R.string.hello);

我也看了看:R.string的变化值programically 但似乎只涉及改变语言,他最后只是以不同的方式。任何人都可以伸出援助之手吗?我也看了看这里: http://developer.android.com/导/主题/资源/串resource.html ,并没有发现任何助阵两种:(

I've also looked at: Change value of R.string programically? but it seems that only involves changing language and he ended up doing it a different way. Can anyone lend a hand please? I've also looked here: http://developer.android.com/guide/topics/resources/string-resource.html and found nothing to help out either :(

推荐答案

您不能改变的strings.xml动态,因为它是一个编译的资源。还有其他的机制来保存数据在Android中,这里是一个很好的贴子,讨论这个话题:数据存储。希望这有助于。

You can't change strings.xml dynamically since it's a compiled resource. There are other mechanisms for saving data in Android, here's a nice post that covers this topic: Data Storage. Hope this helps.

 
精彩推荐
图片推荐