谈到activity_main.xml中 [英] Commenting in activity_main.xml

查看:216
本文介绍了谈到activity_main.xml中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的Andr​​oid。据我所知,在XML注释的工作原理相同,它在HTML中,使用

I am new to Android. I understand that commenting in XML works the same as it does in HTML, using the

<!-- comment here -->

形式。我想写出我activity_main.xml中的配置文件中的一些注释为Android项目,但它给我的错误。值得注意的是,我使用Eclipse,但就目前而言,我直接编辑XML文件,而不是图形,因为我宁愿强迫自己理解的属性。我想评论进出冲突的属性,但它给我冲。

form. I would like to write some comments in my activity_main.xml configuration file for an Android project, but it's giving me errors. It's worth noting that I'm using Eclipse, but for the moment, I'm editing the XML file directly as opposed to graphically because I'd rather force myself to understand the attributes. I am trying to comment in and out conflicting attributes but it's giving me red.

有没有办法为Eclipse让我评论说,特定的XML文件?

Is there a way for Eclipse to allow me to comment that particular XML file?

对于那些问,这里是一个例子:

For those that asked, here's an example:

<EditText android:id="@+id/edit_message"
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"
    android:hint="@string/edit_message" 
    android:layout_weight="1" />

说我想简单地注释掉第二行。我想,因为我在以后使用layout_weight注释掉layout_width标签。当我尝试它注释掉,我得到:

Say I'd like to simply comment out that second line. I want to comment out the layout_width tag because I'm later using layout_weight. When I try to comment it out, I get:

元素型的EditText必须后跟属性规范>或/>\".

Element type "EditText" must be followed by either attribute specifications, ">" or "/>".

一个人回答说,一个注释不能向上突破的标签,这是我打算这样做。我以为自己是在之前做过HTML,所以我认为XML遵守同样的规则遵守。我不这样想,也许我只需要刷上我的XML。

One person responded that a comment can't break up a tag, which is what I intended to do. I thought I had done that before in HTML, so I assumed that XML abided by the same rules. I guess not, or maybe I just need to brush up on my XML.

推荐答案

与XML注释属性的问题是,你不能有一个评论打破XML标记。所以,如果您有:

The problem with commenting attributes on xml is that you can't have a comment break the xml tag. So if you have:

<View 
   android:layout_width="match_parent"
   android:layout_height="match_parent"
/>

您无法发表评论layout_width,您的评论必须是视图标签之外。

You can't comment layout_width, your comment must be outside of the view tag.

这篇关于谈到activity_main.xml中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆