定义xml为drawable文件并根据状态改变显示的图片资源
在Button上触摸按下的时候,Button有focused,pressed和default状态,可以使用不同的图片来显示这三种状态。
先定义一个名为btnselector.xml文件,代码如下:
<?xml version="1.0" encoding="UTF-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_focused="true"
android:state_pressed="false"
android:drawable="@drawable/focused"
></item>
<item
android:state_focused="true"
android:state_pressed="true"
android:drawable="@drawable/focusedpressed"
></item>
<item
android:state_focused="false"
android:state_pressed="true"
android:drawable="@drawable/pressed"
></item>
<item
android:drawable="@drawable/default"
></item>
</selector>
ImageButton使用btnselector.xml如下:
<ImageButton
android:id="@+id/stop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/btnselector"
android:background="#00000000"
></ImageButton>
android:src赋值为"@drawable/btnselector",而不是指向具体的图片资源。
相关文档:
XML的全称Extensible Markup Language,意思是可扩展的标记语言,是标准通用标记语言SGML(Standard Generalized Markup Language)的一个子集。1998年2月,W3C发布了XML1.0标准,其目的是为了在Web上能以现有的超文本标记语言HTML的使用方式提供,接收和处理通用的SGML。XML是SGML的一个简化子集,它以一种开放的,自我描述的 ......
摘要:我们描述一个简单的业务系统的用例,然后介绍不同的实现技术及其比较。我没有做过实际的基于SW技术的信息系统,因此本文只是一些猜想性的东
西,希望抛砖引玉,能得到大家的指教,也欢迎大家补充,谢谢!
注意我们讨论的对象是传统的MIS系统,如图书查询系统,学生管理系统之类的。
用例: 用户在查询界面选择 ......
不需要生成dtd,无用配置,不需要生成辅助类,速度快。这就是xstream+xpp超强黄金组合。
xstream大家都知道啦,XML Pull Parser是一种高速的 解析xml文件的方式,速度要比传统方式快很多(发现pull式解析现在比较流行了)。下面我给出多种使用方法的例子。
1.最简单的使用方法
因为这个太简单,所以我从moogle的blog http: ......