Android: Change strings resource Programmatically

前端 未结 2 908
野趣味
野趣味 2021-01-03 23:54

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

2条回答
  •  再見小時候
    2021-01-04 00:12

    You can update the label on TextView or anything similar.

    • 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)

提交回复
热议问题