skwokie
skwokie

Reputation: 475

The meaning of @android

I would like to ask what is the meaning of @android as in android:id="@android:id/list. I have seen it in different android samples and tutorials, and I have also googled it. The only explanation I found is "The list and empty IDs are provided for us by the Android platform, so, we must prefix the id with android:" from http://developer.android.com/resources/tutorials/notepad/notepad-ex1.html

Thank you.

Upvotes: 3

Views: 1823

Answers (1)

user370305
user370305

Reputation: 109237

android:

Contains resource classes used by applications included in the platform and defines application permissions for system features.

You can use some resources directly from these R classes in your own applications, but you should generally use only resources that you've provided directly in your application, in order to provide a cohesive application package that has no external dependencies. In particular, you should not use drawable resources from the android package, because they may change between platform versions, causing unforeseen conflicts with your design. Typically, styles are the only resources you should use directly from these resources.

So you are using android' resources like list, empty etc.. by using '@android:id' in xml file.

Difference of @+id and @android:id :

@+id/foo means you are creating an id named foo in the namespace of
your application. You can refer to it using @id/foo. @android:id/foo
means you are referring to an id defined in the android namespace.
This namespace is the namespace of the framework. In this case, you
need to use @android:id/list and @android:id/empty because these are
the id the framework expects to find (the framework knows only about
the ids in the android namespace.

Thanks.

Upvotes: 4

Related Questions