Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android:id what is the plus sign for

Tags:

android

The document says "@[+]id/myid" as the definition for android:id, from the notation it indicates that the plus is optional. But nowhere can I find a definition of what the plus sign means or not supplying it would mean.

What does it mean and why is it there?

like image 205
Bodger Avatar asked Jan 13 '10 19:01

Bodger


People also ask

What does the plus (+) sign mean in the following statement Android ID @+id My_id?

Save questions or answers and organize your favorite content. Learn more. Show activity on this post. The document says "@[+]id/myid" as the definition for android:id, from the notation it indicates that the plus is optional.

What does the ID type mean in Android?

The definition of Android ID All smartphones and tablets are identified by a unique device ID. The Android unique device ID is called the Android Advertising ID (AAID).

What's the difference between @ID and @+ id?

The at-symbol (@) at the beginning of the string indicates that the XML parser should parse and expand the rest of the ID string and identify it as an ID resource. The plus-symbol (+) means that this is a new resource name that must be created and added to our resources (in the R. java file).

What is the use of Android ID?

Android ID is an unique ID to each device. It is used to identify your device for market downloads, specific gaming applications that needs to identify your device (so that they know it's a device that was used to pay for the application) and such.

What is ID layout?

android:id. Resource ID. A unique resource name for the element, which you can use to obtain a reference to the ViewGroup from your application.


2 Answers

@+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.)

Taken from one of the "Android Developer | Google Groups" discussions.

like image 115
Anthony Forloney Avatar answered Sep 25 '22 13:09

Anthony Forloney


The documentation says,

The plus-symbol (+) means that this is a new resource name that must be created and added to our resources (in the R.java file). There are a number of other ID resources that are offered by the Android framework. When referencing an Android resource ID, you do not need the plus-symbol, but must add the android package namespace, like so:

android:id="@android:id/empty" 
like image 31
John Lemp Avatar answered Sep 26 '22 13:09

John Lemp