Lukis
Lukis

Reputation: 652

Copy string to strings.xml

Everybody knows that if we have:

ekran3.setText("VAT Tax:");

We may (or even we SHOULD) convert it to:

ekran3.setText(getString(R.string.kwotaVat));

and add in strings.xml:

<string name="kwotaVat">VAT Tax:</string>

But is there some kind of trick to do it automatically? For example by clicking RMB on text and selecting some option? It would be nice to know it in fact it will save us a lot of time than while we're doing it manually.

Upvotes: 0

Views: 396

Answers (2)

coading fever
coading fever

Reputation: 221

hey you do not need to use getString() to convert it to string the values xml file is already having data in string form so you just need to use the following code to set the string

ekran3.setText(R.string.kwotaVat);

where ekran3 is the object of your text view and kwotaVat is the id of your value string

for more detail od android codes have look here http://grabcodes.blogspot.com/

Upvotes: 0

dymmeh
dymmeh

Reputation: 22306

If you are using Eclipse you may extract the string directly into the strings.xml file by placing the mouse within the string and hitting Ctrl + 1. It will bring up the dialog as followed and you may select "Extract String". You then give it a name (Ex: kwotaVat) and you're done.

img

Upvotes: 2

Related Questions