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

Fragments and Tabs

I have been going through the tutorial and i have noticed something.

when i do

android:id="@android:id/list" 

for the login_fragment it works but when i do

android:id="@+id/list"

the app crashes when it starts at first i thought it was one of those API level problems and went through the forum but couldn't find the solution and noticed that the id's declaration were different in the guide and in my code.

So i am wondering and interesting why am i getting an error when i do @+ and why dose it work when i use the first way to declare an Id ?

1 Answer

Hey Derese! "@android:id/list" means that you are using a predefined android resource id called "list", while "@+id/list" means that you are creating a new id with the name "list".

The reason it crashes when you use the second one is probably because you have something like a ListActivity that requires you to have a ListView with the first id.

From the ListActivity documentation:

To do this, your own view MUST contain a ListView object with the id "@android:id/list"