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 a Simple Android App (2014) Creating the Screen Layout Adding a Button

boog690
boog690
8,987 Points

No 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
Oscar Hernandez
1,618 Points

Stephanie 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.

Thanks for answering, I get it now!

Oscar Hernandez
Oscar Hernandez
1,618 Points

You 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.

I 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
Oscar Hernandez
1,618 Points

Stephanie 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.

Hi, 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?