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 trialboog690
8,987 PointsNo android:id for the "Did you know?" TextView?
Is there a reason we don't create an id for the "Did you know?" TextView?
3 Answers
Oscar Hernandez
1,618 PointsStephanie Fu , you will use an id for the button and the Fact Text View, and android studio does not require an id for that. That is why when you add an id to something, you add it manually, for instance, in the xml. for example, when you want to id something you manually put it in in the xml like this
android:id=@+id/factTextView
i hope im making sense, im a beginner as well.
Oscar Hernandez
1,618 PointsYou usually put an ID to something when you want to call it somewhere else, or if you want to do something, and that is usually done in java, like in the Activity files. So, for this app we don't do anything with that textview, so there is no need to ID it. Hope that makes sense.
Stephanie Fu
1,939 PointsI was wondering the same thing - So how does Android Studio know that I want to ID the other two items, but not the "Did You Know" TextView?
Oscar Hernandez
1,618 PointsStephanie Fu , you are the one that decides if you want to id something, you dont have to. it is just to call it in java.
Stephanie Fu
1,939 PointsHi, I know that normally if I code everything, I get to decide if I want to id something, but in this FunFacts app, I haven't done anything with the id code at all, how does Android Studio know to not give "Did You Know?" an id?
Stephanie Fu
1,939 PointsStephanie Fu
1,939 PointsThanks for answering, I get it now!