问题
I'm writing my layouts and every time i type in a @string/new it just warns me that the string reference does not exist, but doesn't show any helper to create it. I have to go to my strings.xml and type in the xml tag for the new string.
The demos show that Android Studio even replaces the code to get strings with the actual strings, but the demo never shows a string being created from zero.
I know that when I'm in the visual editor I can create a new string element on the screen I get if I click the "..." button for the text property, but how do I get this functionality from the textual view of a layout?
回答1:
I haven't used the new Android Studio extension, as it doesn't appear to be stable enough for production use yet, but in plain old IntelliJ IDEA 12, if you use Alt-Enter on the red R.string.foo
reference, the intention menu has "Create string resource" as an item. Selecting that intention brings up the dialog to add the string. From the dialog you can type in the string and select which resource filters to use (i.e. which strings.xml to add it to).
来源:https://stackoverflow.com/questions/16778786/how-should-i-be-creating-strings-in-androidstudio-intellijidea