tags:

views:

90

answers:

3

There are several different ways of definition the ID. What is the difference? android:id="@id/android:list" android:id="@+id/android:list" android:id="@+id/confirm"

A: 

The '+' means add it to your current project's R.java. Those without pluses are resources inherited from the framework.

Jacques René Mesrine
this is what i got from the Dev Guide:android:id="@+id/text1"In this case we create a new id called text1. The + after the @ in the id string indicates that the id should be automatically created as a resource if it does not already exist, so we are defining text1 on the fly and then using it.so, what is the "on the fly" mean?
guobosheng
I think it means @Runtime
Samuh
Think of the externalized XML files as a mini dependency injection framework that defines the object graph of the widgets. As far as I know, the ids with + are for compile time usage (like generics). They tell the development tools in Eclipse what gets written into R.java
Jacques René Mesrine
+1  A: 

+id/label means that your resource will have an id value = label and that label belongs to your application's name space. There are many resources bundled with android.jar file and when referring to these resources you would say android:id = "@android:id/list" which means your resource will have an id value = list and that this value belongs to android name space.

Refer the following for details: http://groups.google.com/group/android-developers/browse_thread/thread/dc8023b221351aa7

Samuh
+3  A: 

android:id="@id/android:list" refers to android.R.id.list. android.R contains resources that are bundled with the platform. There are lots of these standard resources, they are all listed in the JavaDoc.

@+ creates a resource, so android:id="@+id/confirm" creates a new id in your application's R class, ie. R.id.confirm. This is explained in the User Interface > Declaring Layout > ID of the Dev Guide.

I'm not sure you can do android:id="@+id/android:list", as it would mean you are trying to create a resource on the platform's resource class.

Mwanji Ezana