最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
Android 开发Missing contentDescription attribute on image in XML
时间:2013-12-22 编辑:简简单单 来源:一聚教程网
最近在做 Android 开发,刚刚入门,遇到不少问题,累积了做重构时的习惯,遇到问题,好好解决,好好总结,于是整理如下:
一. Eclipse Error
1.'Missing contentDescription attribute on image' in XML
原因:缺少图片描述,在 ADT 16 开始会抛出这个警告,确保开发者为图片添加内容描述。
解决方法:为图片添加 android:contentDescription="@string/desc" 属性。
2. Buttons in button bars should be borderless
原因:两个 Buttons 放在一个布局里会被判断为按钮栏,需要添加样式取消它的边框。
解决方法: 在 Buttons 上添加属性 style="?android:attr/buttonBarButtonStyle" 。系统提示也可以在按钮的父布局上添加 style="? android:attr/buttonBarStyle" 属性,但是我在线性布局上测试了一下无效,求高手指导!
二. 开发技巧
1. 在新打开的 Activity 中触发前一个 Activity 作出调整
例如:原页面相应的 class 为 Main.class (主要代码)
代码如下 | 复制代码 |
public class Main extends Activity { public class NewPage extends Activity { |
如果需要在 Activity 之间传输数据,还可以使用 Bunble 在 intent 中保存和获取数据。
2. 获取列表中被点击事项的位置
扩展 BaseAdapter 类,重写 getView 方法,第一个方法即为事项的位置,若要配合 cursor 使用,则可以使用 cursor.moveToPosition(position) 把 cursor 移动到事项在数据库中相应的数据行。
-
上一个: 手机YY语音无图模式怎么开启
相关文章
- sora软件价格介绍 02-22
- sora官网入口地址一览 02-22
- Sora生成的视频使用教程 02-22
- 《梦幻西游》元宵灯谜线索答案大全2024 02-22
- 《原神》有朋自远方来第一天通关攻略 02-22
- 《苏醒之路》四个结局达成攻略 02-22