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

What am I doing wrong?

So I'm working on the Initialize get answer button code challenge on the Android App development course, and I can't figure out what I did wrong.

TextView answerLabel = (TextView) findViewById(R.id.textView1);     
Button getAnswerButton = (Button) findButtonById(R.id.button1);

5 Answers

Both should be findViewById if I remember correctly.

You rock SO hard

Yes, remember that a 'button' is still a UI view component.

Yeah it at first glance seems counter intuitive from having done a bit of HTML but then I guess a UI view is anything you want to display

Okay working on the Learning the Language Code Challenge, I got the first three right and I can't figure out what I'm doing wrong

Random randomGenerator= new Random();
int randomNumber = randomGenerator.nextInt(10);
answer = Integer.toString(randomNumber);

You haven't declared the type for answer. It should be: String intAsString = Integer.toString(randomNumber);

Thanks Charlie! I was looking for this answer!