ImageView,ImageButton报警(转)

开发程序时,在main.xml中添加空间ImageButton时会有一下警告:

 Missing contentDescription attribute on image

起初不知道怎么办

后来查了一下文档知道了,官方解释如下:

 Resolved this warning by setting attribute android:contentDescription for my ImageView

android:contentDescription="@string/desc"

Android Lint support in ADT 16 throws this warning to ensure that image widgets provide a contentDescription

This defines text that briefly describes content of the view. This property is used primarily for accessibility. Since some views do not have textual representation this attribute can be used for providing such.

Non-textual widgets like ImageViews and ImageButtons should use the contentDescription attribute to specify a textual description of the widget such that screen readers and other accessibility tools can adequately describe the user interface.

大体翻译一下:

解决警告Missing contentDescription attribute on image的方法是添加一下代码

android:contentDescription="@string/desc"(注意,这里的desc指的是你对自己程序的描述,这段描述定义在string.xml里面)

提示:其实这段描述是什么这个不重要,你可以引用string里面的任何一个字符串

安卓的这个ADT16发出这个警告的目的是为了让你对已定义的image控件进行描述

控件的这一特性主要是起到辅助作用的。由于无文本控件没有描述性功能的文字说明,所以imagebutton,imageview这写控件描述性的定义就能起到与代码阅读者或者是其他工具进行衔接的功能!

posted @ 2012-08-13 09:17  肆意感受  阅读(489)  评论(0编辑  收藏  举报