15

Is there any Eclipse plugin that takes strings from code and puts them in strings.xml? I found "Externalize strings" function in Eclipse, but I don't know how to get it to work with strings.xml.

Denis Palnitsky
  • 18,267
  • 14
  • 46
  • 55
  • 2
    That'd be amazingly useful wouldn't it? I can't seem to break the habit of writing strings in Java and then manually moving them to resources much later on... a tool to automate this would be very handy indeed. – Reuben Scratton Dec 24 '10 at 17:20

3 Answers3

31

Use Refactor in Eclipse:

  • highlight the string
  • From the Eclipse menu select Refactor -> Android -> Extract Android String.

The string will be moved to strings.xml and the call to getContext().getString(R.string.my_string) generated.

Patrick
  • 11,552
  • 7
  • 29
  • 41
Diego Torres Milano
  • 65,697
  • 9
  • 111
  • 134
5

You can also position your cursor over the string literal and press ctrl+1. Then choose "externalize" by the android icon.

Credits: Do externalized strings need to be in strings.xml?

Community
  • 1
  • 1
Cléssio Mendes
  • 996
  • 1
  • 9
  • 25
0

use shortcut Alt+Shift+A and after that press S. it'll solve your problem.

MANISH PATHAK
  • 2,602
  • 4
  • 27
  • 31