Android:以编程方式更改字符串资源

标签 android string resources

有没有办法做到这一点?例如,我的首选项中有一个设置可以在公制和标准测量单位之间转换,当用户更改此设置时,我想更新一些字符串以更改我的应用程序中的一些标签。

最佳答案

您可以更新 TextView 或类似内容上的标签。

  • 使用 update_str = Context.getResources().getString (R.string.update_identifier) 获取更新后的字符串
  • 使用 ((TextView)findViewById (R.id.textview)).setText (updated_str)
  • 更新标签

关于Android:以编程方式更改字符串资源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6936800/

相关文章:

android:state_pressed 不工作

android - 创建使图像相互淡入淡出并转换的幻灯片放映

android - Android 中的 greenrobot EventBus 发布事件

android - FFmpeg libavcodec/encode.c 无法编译

java - 为什么会延迟生成 Java String 哈希码?

python - Pandas DF : Create New Col by removing last word from of existing column

excel - 如何下载到 Excel?

android - 我如何检测android中特定包的删除?

c# - 用于验证逻辑 && || 的正则表达式字符串中的运算符

CSS #{resource} 版本控制