15

When I'm working on Android project I would like to use some magic shortcut that would extract my string to strings.xml and also allow me to change the key. Is there any?

If there isn't, is there a way to develop new refactorization methods and extend IntelliJ possibilities?

Michal Chudy
  • 1,883
  • 2
  • 21
  • 41

3 Answers3

21

Alt+Enter (to invoke intention action menu) on a string, then use Add a string resource action from the menu.

To rename resource use Refactor | Rename while standing on a resource name in Java code, it will rename all the references and the resource itself.

CrazyCoder
  • 389,263
  • 172
  • 990
  • 904
  • In layout files it works a bit different, you specify new resource name, it gets highlighted in red and there is an intention to create the resource. Extracting string to resource from the layout will be supported in the future updates. – CrazyCoder Dec 13 '11 at 12:28
  • @MichalLevý, here is the feature planned for IDEA 11.1: http://youtrack.jetbrains.net/issue/IDEA-63248 – CrazyCoder Dec 13 '11 at 12:56
0

If you're using eclipse, you can highlight the string you want extracted to strings.xml, press Alt + Shift + A and in the small pop-up on the lower right of the screen select "Extract Android String"

Juri
  • 1
0

There is the Eclipse's option: Source / Externalize strings, which externalizes the strings of a class into a .properties file, but it does not seem to be able to export them directly to strings.xml in the Android way.