1

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?

1

2 Answers 2

2

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?

Sign up to request clarification or add additional context in comments.

Comments

1

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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.