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
Michael Foster
7,801 PointsHaving trouble with Android Studio, please help!
I have just created a new project in which I am using ActivityA and ActivityB for my activity names. In addition I also named activity_layout for my layout name. When the project is created and loads up in android studio, I am receiving a error message after clicking on the first activity which is activityA. The error message states this "<identifier> expected" and will not run app. Please take a look at the code on line 27 where there is a wiggle line under a common which is causing the error. Thanks!
1 Answer
Jon Kussmann
Courses Plus Student 7,254 PointsHi Michael,
In your onCreateOptionsMenu() method you have the following line:
getMenuInflater().inflate(R.menu., menu);
You should have a reference to a menu like R.menu.menu_main.
If you don't want to have a menu for your application for now, you can safely delete the entire onCreateOptionsMenu() method, or alternatively add an appropriate menu.
I hope this helps.
Michael Foster
7,801 PointsThanks! I have been trying to fix this issue for the last 12hours and every time I try to reference something it just turns the color red and the wiggle line is gone. I will have to do without the menu options for now I guess but i really do appreciate your feed back. Thanks again Jon, great job with such a quick response!
Michael Foster
7,801 PointsMichael Foster
7,801 Pointspackage Hour2App.hour2app;
import android.app.Activity; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.EditText; import android.widget.TextView;
public class ActivityB extends Activity {
}
This line of code in the code above I receive a wiggle line under the comma after the first menu.(R.menu.,)
getMenuInflater().inflate(R.menu., menu);