Android的:改变字符串资源编程 [英] Android: Change strings resource Programmatically
本文介绍了Android的:改变字符串资源编程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法做到这一点?举例来说,我在我的preferences可度量和测量的标准单位,当用户改变这一点,我想更新一些字符串在我的应用程序,改变周围的一些标签之间转换的设置。
Is there a way to do this? For instance, I have a setting in my preferences that can convert between metric and standard units of measurement and when the user changes this I would like to update a few strings to change some labels around within my app.
推荐答案
您可以在TextView中或任何类似的更新标签。
You can update the label on TextView or anything similar.
- 使用获取更新后的字符串
update_str = Context.getResources()的getString(R.string.update_identifier)
- 使用更新标签
((TextView中)findViewById(R.id.textview))。的setText(updated_str)
- Get the updated string using
update_str = Context.getResources().getString (R.string.update_identifier)
- Update the label using
((TextView)findViewById (R.id.textview)).setText (updated_str)
这篇关于Android的:改变字符串资源编程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文