Android的:改变字符串资源编程字符串、资源、Android

2023-09-06 02:22:33 作者:ぁ專屬的鬽力¥

有没有办法做到这一点?举例来说,我在我的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)