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 Build a Simple Android App (retired 2014) Getting Started with Android Accessing Views in Code

code problem

syntax errors add button1

Ethan Lowry
Ethan Lowry
Courses Plus Student 7,323 Points

You're going to have to provide your relevant section of code and the exact error logs you're getting if people are going to be able to help you at all.

// Declare our view variables TextView answerLabel = (TextView) findViewById(R.id.textView1);
Button getAnswerButton = (Button) findViewById(R.id.Button1); }

Ben Junya
Ben Junya
12,365 Points

Hey dude, we can't help you if we don't know exactly what's going on. It's extremely difficult for any of us here to know what you're talking about. Are you trying to add a button in the XML layout? Or are you trying to set a Button variable in your activity? We don't know what you're asking of us. At the very least, maybe copy and paste in your code and tell us what the problem is.

1 Answer

What I can infer from your code is it should't be R.id.Button1, but R.id.button1 ... button with a small b unless you have specified it with a capital letter otherwise

Hope that helps