android listview 背景图片的问题
我想在listview的一个item失去焦点的时候更改list的item的背景图片应该怎么办?<?xmlversion="1.0"encoding="UTF-8"?><s...
我想在listview的一个item失去焦点的时候更改list 的item的背景图片 应该怎么办?
<?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="true"
android:drawable="@drawable/btn_media_player_pressed" />
<item android:state_focused="false" android:state_pressed="true"
android:drawable="@drawable/button" />
<item android:state_focused="true"
android:drawable="@drawable/btn_media_player_selected" />
<item android:state_focused="false"
android:drawable="@drawable/button" />
<item android:state_focused="false" android:state_pressed="false"
android:drawable="@drawable/button" />
</selector>
这种方式的话 默认的图片应该怎么写
如果用setOnFocusChangeListener应该怎么写? 展开
<?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="true"
android:drawable="@drawable/btn_media_player_pressed" />
<item android:state_focused="false" android:state_pressed="true"
android:drawable="@drawable/button" />
<item android:state_focused="true"
android:drawable="@drawable/btn_media_player_selected" />
<item android:state_focused="false"
android:drawable="@drawable/button" />
<item android:state_focused="false" android:state_pressed="false"
android:drawable="@drawable/button" />
</selector>
这种方式的话 默认的图片应该怎么写
如果用setOnFocusChangeListener应该怎么写? 展开
1个回答
展开全部
<?xml version="1.0" encoding="utf-8" ?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_window_focused="false"
android:drawable="@drawable/没有焦点时的图片背景" />
<item android:state_focused="true" android:state_pressed="true"
android:drawable=
"@drawable/非触摸模式下获得焦点并单击时的背景图片" />
<item android:state_focused="false" android:state_pressed="true"
android:drawable="@drawable/触摸模式下单击时的背景图片" />
<item android:state_selected="true"
android:drawable="@drawable/选中时的图片背景" />
<item android:state_focused="true"
android:drawable="@drawable/获得焦点时的图片背景" />
</selector>
试试
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_window_focused="false"
android:drawable="@drawable/没有焦点时的图片背景" />
<item android:state_focused="true" android:state_pressed="true"
android:drawable=
"@drawable/非触摸模式下获得焦点并单击时的背景图片" />
<item android:state_focused="false" android:state_pressed="true"
android:drawable="@drawable/触摸模式下单击时的背景图片" />
<item android:state_selected="true"
android:drawable="@drawable/选中时的图片背景" />
<item android:state_focused="true"
android:drawable="@drawable/获得焦点时的图片背景" />
</selector>
试试
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询