How can I comment in xml file of android layout. I have seen Comments in Android Layout xml - but I wanted to comment inside a parent.
When I try to do that I get an error in eclipse:
<Button android:text="Button" <!-- this is a comment --> android:id="@+id/Discon" > </Button>
From the background knowledge of xml, I came to know that we cannot add comments in attributes. Is there any way of removing the id as attribute and specifying it as element?
Or is there any way to add comments inside attributes of elements?
alt + c then alt + l (holding alt ) for line comment.
An XML comment encountered outside the document type declaration is represented by the Comment value syntax element. It contains the comment text from the XML message. If the value of the element contains the character sequence --> , the sequence is replaced with the text --> .
If you want to comment out a single line in the XML code, insert your cursor at the beginning of a line you want to comment out. Type a less-than symbol followed by an exclamation point and two dashes. Move your cursor to the end of the line and then type two dashes followed by a greater-than symbol.
Using Android's XML vocabulary, you can quickly design UI layouts and the screen elements they contain, in the same way you create web pages in HTML — with a series of nested elements. Each layout file must contain exactly one root element, which must be a View or ViewGroup object.
you cannot embed a comment inside a tag. between tags it's not a problem
<!-- this is a comment --> <Button android:text="Button" android:id="@+id/Discon" > </Button>
if you want to temporary comment out an attribute (if that's what you want to know) you will have to move it ouside the tag and comment it there.
<Button android:text="Button" android:id="@+id/Discon" > </Button> ==> <!-- android:id="@+id/Discon" --> <Button android:text="Button" > </Button>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With