如何在Android的XML文件中添加注释 本文转载自http://blog.csdn.net/pipisorry/article/details/24833325,感谢原创大神!
来源:互联网 发布:win7与linux双系统 编辑:程序博客网 时间:2024/05/16 11:37
http://blog.csdn.net/
android:id="@+id/item_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<!-- -->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<!-- -->
</LinearLayout>
</RelativeLayout>
虽然可以正常运行,但是这不是一个好习惯(如果你有个string="确定"在多个地方都用到,但是后来你想把它改为“确认”,你觉得是找到引用它的地方一个个改方便呢,还是直接在strings.xml里面改一处方便?你只看到了strings中增加了一条记录),应该在res/values/strings.xml中设置:copy引用的时候使用就行了。这样做可以做到一改全改,在支持多语言时也是很有用的。另外,颜色的设置也最好在color.xm中类似设置。/article/details/24833325
怎么在android的XML文件中添加注释
Android的XML文件注释一般采用 <!--注释内容 -->的方式进行
在XML中,形如 <Button /> 的表示方式,其中“/>”的含义表示这个XML中没有内文,他是一个最小组成单元,也就是说他的中间不能包含其他任何< >的代码,所以在<Button />中间注释会出现错误
注意看到,在注释的前面有一个“>”符号,这就是我们能够在他中间进行注释的原因,他的完整结构是
<RelativeLayout ></RelativeLayout>
这就不是最小组成单元的表示方式了
- <?xml version="1.0" encoding="utf-8"?>
- <RelativeLayout android:id="@+id/right"
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent">
- <!-- 在这里注释是没有问题的 -->
- <TextView android:id="@+id/right_view1"
- android:background="@drawable/yellow" android:layout_width="fill_parent"
- android:layout_height="wrap_content" android:text="第二组第一项" />
- <!-- 在这里注释也是没有问题的 -->
- <TextView android:id="@+id/right_view2"
- android:background="@drawable/blue"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_below="@id/right_view1" android:text="第二组第二项" />
- </RelativeLayout>
即只能在组件布局代码后,或者在组件的前面添加注释。如下所示:
<RelativeLayoutandroid:id="@+id/item_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<!-- -->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<!-- -->
</LinearLayout>
</RelativeLayout>
相关错误解决
Hardcoded string "???", should use @string resource
在布局文件中,文本的设置使用如下写法时会有警告:Hardcoded string "下一步", should use @string resourcecopy
- <Button
- android:id="@+id/button1"
- android:layout_width="118dp"
- android:layout_height="wrap_content"
- android:text="下一步" />"
- <?xml version="1.0" encoding="utf-8"?>
- <resources>
- <string name="message">下一步</string>
- </resources>
阅读全文
0 0
- 如何在Android的XML文件中添加注释 本文转载自http://blog.csdn.net/pipisorry/article/details/24833325,感谢原创大神!
- C++ 虚函数表解析 本文转载自:http://blog.csdn.net/haoel/article/details/1948051/
- Java的XML创建、解析文档(转载自http://blog.csdn.net/psyuhen/article/details/7539228)
- 转载出处:http://blog.csdn.net/lmj623565791/article/details/52761658; 本文出自:【张鸿洋的博客】
- 转载自http://blog.csdn.net/fei20072050104/article/details/21785565
- 转载自:http://blog.csdn.net/lmj623565791/article/details/24015867
- 转载自 http://blog.csdn.net/racehorse/article/details/6593719
- 转载自http://blog.csdn.net/zhengzhihust/article/details/44151785
- 转载自http://blog.csdn.net/huxu981598436/article/details/51626569
- 转载自http://blog.csdn.net/lwyygydx/article/details/41870377
- 转载自:http://blog.csdn.net/go_hyp/article/details/53693058
- 转载自 http://blog.csdn.net/bieleyang/article/details/76973220
- 转载自http://blog.csdn.net/wwww1988600/article/details/7309070
- QT 如何使图片像素变小的问题(转载自http://blog.csdn.net/sylwlw/article/details/7732038)
- oracle调优总结 本文转自:http://blog.csdn.net/wonth/article/details/1670366
- ImageLoader(转载请注明本文出自xiaanming的博客(http://blog.csdn.net/xiaanming/article/details/26810303))
- C++的内存管理(转载自:http://blog.csdn.net/bizhu12/article/details/6668834)
- dispatch_get_main_queue 转载自http://blog.csdn.net/nono_love_lilith/article/details/7829557 的空间
- 石子合并
- 防止用户误操作Back键
- 2017-11-3 Linux盘格式化、挂载、手动增加swap空间
- css创建表格
- CentOS 7 安装Python3以及pip3
- 如何在Android的XML文件中添加注释 本文转载自http://blog.csdn.net/pipisorry/article/details/24833325,感谢原创大神!
- Struts2的多文件上传 和 单文件下载
- 显示
- 响应式布局
- 这些是优秀设计师无法拒绝的设计逆天神器,你在用吗?
- 这8份前沿Paper+Code ,你一定用得上!
- 近期活动盘点:数据标准化及治理大会、IBM苏中讲座、产业创新交流会、企业走访和数据法学征稿(11.6-11.12)
- JavaWeb学习总结
- 搜索入门