求帮助GridView技术问题

Android 码拜 8年前 (2016-05-14) 1030次浏览
GridView  每个  item 是这个  imageview还有textview,要实现点击item的时候   更换 imageview图片,松开的时候变回原来图片
问一下  有什么 好的实现方法
解决方案

20

pic.xml

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

pic_pre 按住状态的图片,pic初始状态图片
然后在布局文件中设置下显示的drawable是pic.xml就可以了


CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明求帮助GridView技术问题
喜欢 (0)
[1034331897@qq.com]
分享 (0)