编程R.String的变化值 [英] Changing value of R.String Programmatically

查看:172
本文介绍了编程R.String的变化值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你能不能改变编程方式在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.

这篇关于编程R.String的变化值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆