0
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/hello_world"/>

<string name="hello_world">Hello world!</string>

i want to get the key "hello_world" dynamically during runtime in my fragment

duke
  • 51
  • 4
  • You already have done in this line `android:text="@string/hello_world"`. – Saurabh Bhandari Apr 27 '18 at 12:29
  • @SaurabhBhandari i want get the string key "hello_world", not the value of the string "Hello world!" – duke Apr 27 '18 at 12:33
  • `String mystring = getResources().getString(R.string.hello_world);`. (see https://stackoverflow.com/a/7493367/6523232) – N0un Apr 27 '18 at 12:35
  • 2
    Possible duplicate of [How to get the id of a string resource associated with a TextView?](https://stackoverflow.com/questions/47035362/how-to-get-the-id-of-a-string-resource-associated-with-a-textview) – Christopher Apr 27 '18 at 12:42
  • 1
    Possible duplicate of [How to get Resource Name from Resource id](https://stackoverflow.com/questions/10137692/how-to-get-resource-name-from-resource-id) – AskNilesh Apr 27 '18 at 12:42

0 Answers0