Today reading a tutorial i see the XML layout and see some elements have a id like
android:id="@android:id/element_id"
others have the regular android:id
android:id="@+id/element_id"
What is the difference between these two lines?
Today reading a tutorial i see the XML layout and see some elements have a id like
android:id="@android:id/element_id"
others have the regular android:id
android:id="@+id/element_id"
What is the difference between these two lines?
the one with the '+' will force the compiler to create that element in your R.java. You use the + when it is the first time creating a reference to that id. In other elements that refer to it, you do not need the '+' since its static entry in the R.java will already be there. A more eloquent explanation of this same issue is found here : what is the difference betwenn @id/ and @+id/ in android?
The first one is using an ID defined by the Android framework (hence, the android:
prefix).
The second one is declaring a new ID for use within your app.