Why the plus sign for identification resources in the name of the names in Android

I could not come up with a better name for this question, so please feel free to fix it if you can.

So here is my question. I decided to write a small application for myself, and along the way I also try to better learn Android Development. I know why there is a + (plus) sign in the android:id attribute, as this means "creating a new id resource". But I don't know why Android should put + in the ones used for links, for example below:

Here I have two buttons named StartButton and StopButton , and since they are new resources, android:id contains + :

  <Button android:id="@+id/StartButton" android:layout_width="150dp" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_below="@+id/textView1" android:layout_marginTop="53dp" android:textSize="18dp" android:text="Start" android:onClick="StartButton_OnClick" /> <Button android:id="@+id/StopButton" android:layout_width="150dp" android:layout_height="wrap_content" android:layout_alignTop="@+id/StartButton" android:layout_toRightOf="@+id/StartButton" android:text="Stop" android:textSize="18dp" tools:context=".CallerBlockerActivity" android:onClick="StopButton_OnClick" /> 

But why android:layout_alignTop contains + puzzles, since id/StartButton is determined when @id/StopButton reaches it. Can someone explain the need for this syntax?

+4
source share
1 answer

It doesn’t matter in any case - for the first link to the identifier there should be only +. If the identifier is already defined, in any case, the + symbol is ignored. You could put a + in front of each link in XML if you want, and everything will work as expected. This is only necessary for the first link.

+5
source

All Articles