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 is the purpose of ID in Android

I saw in the video that the ID names were changed. However, i did not understand the concept and the utility of IDs here. What is ID called in Java? Also, why are we using camel case for ID?

1 Answer

An ID uniquely identifies an element, such as a TextView or Button, within the application. Since there can be multiple text views or buttons within a class/within the application, each need to have a unique name. It is also the ID that you will call on to to change properties of said item or to otherwise refer to it in your code. I am not sure, but camel case is just a convention. I do not believe there is a functional requirement to use camel case when naming anything within your code. That said, there are definitely situations where case does matter, as when declaring a new string variable, the data type (I am pretty sure) must be String and not string. I am pretty new to all of this myself, so hopefully I am not leading you astray.