small medium large xlarge

18 Sep 2011, 07:39
Effe Speeden (2 posts)

Does anyone know how to add comments to Android XML files within tags? Apparently, this is not permitted:

<!-- comment -->
18 Sep 2011, 16:25
apple muncy (34 posts)

Before or after but not in a tag.

19 Sep 2011, 17:12
Joe McGerald (14 posts)

That works OK for me. The easiest way is to write your comment (single or multi-line) then highlight it, click on: Source–>Toggle comment or … Source–>Add Block comment.

That approach works in both XML and Java class files.


20 Sep 2011, 19:50
apple muncy (34 posts)

Hm, so at random I pick /res/values/strings.xml and insert some random text, high lightlight it, and click Source->add Block comment.

<string name="about_header">About Simply Recipes</string>
<string name="about_summary"
<!-- sdfgdsfgdsfhdfgg -->
>Simply Recipes allows you to manage your recipes and share them with friends.</string>
<string name="main_about_button">About</string>

Fine, Well and good until I compile it. Then the compiler screams: Element type “string” must be followed by either attribute specifications, “>” or “/>”.

Maybe you did not understand the part about inside a tag?

21 Sep 2011, 14:53
Effe Speeden (2 posts)

Thank you all for your contributions!

29 Sep 2011, 15:31
Ed Burnette (1341 posts)

I’ve often wished there was a way to comment bits of XML inside a tag. I mean, what would have been hard about supporting “//” or “#” at the front to mean “ignore the rest of this line”? Sadly there isn’t a way, so just move the part you want to comment up a few lines until it’s outside any tag and then comment it. By outside any tag I mean not between the @<@ and the @>@.

You must be logged in to comment