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 an Interactive Story App Intents and Multiple Activities Getting Text from an EditText

Arcee Palabrica
Arcee Palabrica
8,100 Points

Clarification on startButton

Just wanna clarify this one...

startButton /*1st*/ = (Button) findViewById(R.id.startButton/*2nd*/);

the 1st startButton is the reference to Button and the 2nd one is the id right? coz in the previous course we made use of the 'm' convention this time there's none.

3 Answers

Hi there,

The first one is how the Java code refers to your GUI element, the second is what the XML references the element with. So, you hook up one to the other, allowing your code to use that element of the GUI.

In short, yes, your understanding is correct. :+1:

Steve.

No problem! :+1: :smile:

Garry Barlow
Garry Barlow
2,210 Points

I had the same issues. I capitalised the S in StartButton and it worked??

Hi Garry,

If you declared the button at the top of your code with a capital S:

Button StartButton;

Then you can initialize it further down using the same name:

StartButton = (Button) findViewById(R.id.startButton);

The two references need to match. The convention is to not use a capitalised initial letter for variables/instances; the capital letter is reserved for class names and some datatypes, e.g. String.

Steve.

Garry Barlow
Garry Barlow
2,210 Points

Great Thanks, Steve. Back on track!

:+1: :+1: :+1: :+1: