Reputation: 301
I am new to android Studio. I have placed a textView widget on my canvas.
I am following a tutorial which states I can now double-click on this widget which should bring up the "Resources Menu" - this doesn't happen however.
The end goal is to extract a String resource using the Resources Menu and automatically place it in strings.xml.
Can anybody shed any light on how I will get this menu up?
GF
Upvotes: 1
Views: 448
Reputation: 1
yes the correct answer is "Then, put the cursor on the string you want to replace with an ID, click ALT+ENTER, then Enter again to "Extract string resource":"
Upvotes: 0
Reputation: 167
The easiest way to create a string resource for text used inside a textView is to switch to the Text format of the Layout. You can switch between the Design and Text view using the tabs at the bottom of the layout.
Then, put the cursor on the string you want to replace with an ID, click ALT+ENTER, then Enter again to "Extract string resource":
That will bring up the properties of the string resource:
There, you can add the "Resource Name". Once you do that, the string inside the xml will be replaced by its ID:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hellostring" />
And the value of the string will now be in the /res/values/strings file, like
<resources>
<string name="app_name">My Application</string>
<string name="action_settings">Settings</string>
<string name="hellostring">Hello World!</string>
</resources>
Upvotes: 4