今天又作茧自缚(item 写成 itme ╮(╯▽╰)╭ elipse还自动闭合了标签,来回查查查看报错,为啥点击无效呢!)

真欠抽,怪不得上班地铁上被个sb踢到脚趾头(目测有可能是同家公司的..同站下车他直奔中行ATM,西楼面熟)

在drawable下建的xml,IDE选selector类型

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:drawable="@drawable/btn" android:state_pressed="false"></item>
<item android:drawable="@drawable/btnhover" android:state_pressed="true"></item>
</selector>

layout中的主文件main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.narumi.android_7_3.MainActivity" > <ImageButton
android:id="@+id/imageButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/mybutton"
android:background="@drawable/btn"
/> </RelativeLayout>

一行java也不用写,p了两张图片,此例结束。

备注:

android:state_pressed 是否按下,如一个按钮触摸或者点击。
android:state_focused 是否取得焦点,比如用户选择了一个文本框。
android:state_hovered 光标是否悬停,通常与focused state相同,它是4.0的新特性
android:state_selected 被选中,它与focus并不相同,如一个list view 被选中,它的各个子组件可能通过方向键被选中。
android:state_checkable 组件是否能被check。如:RadioButton是可以被check的。
android:state_checked 被checked了,如:一个RadioButton可以被check了。
android:state_enabled 能够接受触摸或者点击事件
android:state_activated 被激活。
android:state_window_focused 应用程序是否在前台,当有通知栏拉下或者对话框弹出的时候应用程序就不在前台了。

如果有多个item,程序将自动从上到下匹配,最先匹配的将得到应用。(不是通过最佳匹配)

如果一个item没有任何的状态说明,那么它将可以被任何一个状态匹配。

最新文章

  1. codevs 2287 火车站
  2. web 前端常用组件【02】Select 下拉框
  3. 【转】crontab定时任务中文乱码问题
  4. 360safe安全卫士防网站攻击源码
  5. 获取用户的真实ip
  6. [iOS翻译]《iOS 7 Programming Pushing the Limits》系列:你可能不知道的Objective-C技巧
  7. C#委托初探
  8. jQuery控制CSS样式
  9. 使用WITH AS提高性能简化嵌套SQL(转载)
  10. linux 下查看机器是cpu是几核的
  11. bzoj1085
  12. 2.2 文件 I/O 的基石:Path
  13. HTML解决div里面img的缝隙问题
  14. linq 中执行方法
  15. 【Socket】Java Socket基础编程
  16. fiddler 抓取 nodejs
  17. PHP 通过fsockopen函数获取远程网页源码
  18. RabbitMQ环境安装
  19. div学习之div中dl-dt-dd的详解
  20. cadence分列元件原理图库的设计

热门文章

  1. Optimizing Linux network TCP/IP kernel parameters
  2. java程序员从笨鸟到菜鸟系列
  3. struts2 相关知识
  4. 2014年最新720多套Android源码2.0GB免费一次性打包下载
  5. jquery中Live方法不可用,Jquery中Live方法失效
  6. Javascript基础学习(1)_类型、值和变量
  7. java.sql.Date to java.util.Date
  8. sql 删除表数据truncate delete drop的区别
  9. 安装cocoaPod 的问题
  10. jQuery AJAX load() 方法