
Arcee Palabrica
8,099 PointsClarification 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

Steve Hunter
Treehouse Moderator 57,557 PointsHi 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.
Steve.

Garry Barlow
2,210 PointsI had the same issues. I capitalised the S in StartButton and it worked??

Steve Hunter
Treehouse Moderator 57,557 PointsHi 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
2,210 PointsGreat Thanks, Steve. Back on track!
Arcee Palabrica
8,099 PointsArcee Palabrica
8,099 PointsSteve Hunter thanks man. :)
Steve Hunter
Treehouse Moderator 57,557 PointsSteve Hunter
Treehouse Moderator 57,557 PointsNo problem!
