Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android

"activity_main cannot be resolved or is not a field"

Hi guys, i have a problem with this error. Yesterday when i closed eclipse everything worked fine, but when i start eclipse today this error appear: "activity_main cannot be resolved or is not a field"

Can anyone help me out?

When do you get that error? and where do you see it?

In this line of code:

public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.activity_main, menu); return true; } The error is underlined by activity_main and this error appeared in the MainActivity.java. The error appeared when i started eclipse today, when i closed eclipse yesterday everything was fine.

Tnx for helping man

3 Answers

You should have the following: (notice .inflate(R.menu.main, menu))

 @Override
    public boolean onCreateOptionsMenu(Menu menu) {

        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

Hopefully that helps! Let me know!

Thanks man! It works fine now!

Ma pleasure my man!