I am new to Android development.
I noticed that sometimes @+id
was used instead of @id
. From what I could find, apparently when you compile a program, it first scans the source data and the @+id
tells it to add the id to the R file, and then after that it is considered okay to use @id
.
Is there a good practice to use for this? Could I theoretically always use @+id
to be safe? What about using @+id
once to add it to R, and then removing the plus sign now that it's already present?
Or is there an accepted practice of where the @+id
version is to be declared if @id
is to be used everywhere else?
I think generally if you are assigning an id to a view @+id
, referring to a view @id
<Button
android:id="@+id/start"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<Button
android:id="@+id/check"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/start"
/>