British Bulldog
British Bulldog

Reputation: 1

Import R (android)

I have a problem with my code which refuses to go away. This is the first half of my code:


public class SampleGame extends AndroidGame {

public static String map;
boolean firstTimeCreate = true;

@Override
public Screen getInitScreen() {

    if (firstTimeCreate) {
        Assets.load(this);
        firstTimeCreate = false;
    }

    InputStream is = getResources().openRawResource(R.raw.map1);
    map = convertStreamToString(is);

    return new SplashLoadingScreen(this);

}

An error message is generated on the line

InputStream is = getResources().openRawResource(R.raw.map1)

The error message says I should add the line "import android.R", but when I do this, a second error message is generated which says "map1 cannot be resolved or is not a field." Can someone please give me any suggestions on how to solve this intractable problem?

Upvotes: 0

Views: 300

Answers (2)

Asiimwe
Asiimwe

Reputation: 2259

Try updating your Eclipse android ADT to the latest, restart it. Im not very good at android but if yours does have an onCreate some where make sure u reference your Resources after it has done the onCreate stuff.

Upvotes: 1

hasanghaforian
hasanghaforian

Reputation: 14022

Be sure that there is map1 in Raw folder.If it exists,then try clean/build your project or close and reopen eclipse.It may be solved.

Upvotes: 1

Related Questions