0

I'm currently working on internationalization to my android application. This is the way I try to get the strings from the string.xml

tv.setText(context.getResources().getString(R.string.));

But Eclipse does not suggest any of my pre defined strings, just the standard Android Strings. My Folder structure look like this:

res/values/strings.xml  

and

res/values-NO/strings.xml

I can see that the strings in these to files has some memory addresses in the R.java file, like this one for instance:

public static final int enterPassword=0x7f06003c;

I tried to Clean the Project, but its strange that eclipse doesnt suggest anything, the string exist in the R.java

Where is the problem ?

Lucifer
  • 29,392
  • 25
  • 90
  • 143
Tobias Moe Thorstensen
  • 8,861
  • 16
  • 75
  • 143

6 Answers6

6

You should import you R class.

import xxx.xxx.R;

not

import android.R;

Pasha
  • 2,407
  • 18
  • 25
4

your xml looks like this:

       <?xml version="1.0" encoding="utf-8"?>
     <resources>
      <string name="yellow">Yellow</string>
    </resources>

and in java code:

  tv.setText(getResources().getString(R.string.yellow));

and import android.R eventhough error exists than try to run the program than it will go off

G M Ramesh
  • 3,420
  • 9
  • 37
  • 53
1

import R with your Package Path instead of android.

like import com.example.R

instead of import android.R;

Priyank Patel
  • 12,244
  • 8
  • 65
  • 85
0

Please verify the imported R file path Link for more information

Community
  • 1
  • 1
Dev.Sinto
  • 6,802
  • 8
  • 36
  • 54
0

try this

Resources resources = getResources();

        String string = resources.getString(R.string.text);

              TextView tv= (TextView)findViewById(R.id.text);
                tv.settext(string);
Naveen Kumar
  • 3,738
  • 4
  • 29
  • 50
0

Use this:

String tab_label = getResources().getString(R.string.));

and ensure that you are not imported android.R

Pang
  • 9,564
  • 146
  • 81
  • 122
Asha Soman
  • 302
  • 2
  • 6
  • 18