For some Android XML attributes, you don't conclude the opening tag with a '>' until after you've inserted your formatting components. For example:
<EditText
android:id="@+id/etEmails">
</EditText>
Why is there no definition for the EditText component within the opening and closing tags?
Also, I noticed that some don't even require closing tags and are just in themselves XML statements. For example:
<Button
android:text="Subtract 1"
android:id="@+id/buttSub"
/>
Why does this XML statement not require a closing statement when it practically provides the same components as the EditText field?
Is there a failsafe way of knowing which ones require opening and
closing statements for proper syntax?
Is there a list/reference for which ones do and don't?
What's the difference between these different components?
The <Button />
is a so called short tag. This is safe.
If a tag has no body you can obmit the closing tag and add a slash at the end of the tag which means here this tag has no children.
This notation is very common in xhtml for <br />
and <img src="" alt="" />
tags.
The benifit is that you don't need to write the closing tag which makes it simpler to read and if you have a huge xml file there are less data to transport. (This does not count for Android is this case, because the android SDK procudes internally a binary file.)
If no other element like this for example <something></something>
is inside another element then the end tag />
can be used. So in your example the EditText can end also with the />
tag.
When you want to add another element to your EditText then you need to close the XML of EditText with .
for '>' write in XML
please write as mention below
android:text="Subtract > 1"