How should I be creating strings in AndroidStudio / intellijidea?

余生长醉 提交于 2019-12-10 19:57:46

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!