按下时设置 ListView 选择器颜色时出现问题
我有以下 ListView,并且遵循了这个 SO Question 的答案,但没有运气:
Android ListView Selector Color
<ListView android:layout_width="fill_parent"
android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ARListView"
android:background="@drawable/transparent_background"
android:cacheColorHint="#00000000"
android:listSelector="@drawable/ar_selector"
android:drawSelectorOnTop="true">
这是我的 ar_selector.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false" android:state_focused="true"
android:drawable="@android:color/transparent" />
<item android:state_pressed="true"
android:drawable="@color/solid_red" />
<item android:state_focused="true"
android:drawable="@android:color/transparent" />
</selector>
当我按下 ListViewItem 时,什么也没有出现。
I have the following ListView, and have followed the answer from this SO Question w/ no luck:
Android ListView Selector Color
<ListView android:layout_width="fill_parent"
android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ARListView"
android:background="@drawable/transparent_background"
android:cacheColorHint="#00000000"
android:listSelector="@drawable/ar_selector"
android:drawSelectorOnTop="true">
Here is my ar_selector.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false" android:state_focused="true"
android:drawable="@android:color/transparent" />
<item android:state_pressed="true"
android:drawable="@color/solid_red" />
<item android:state_focused="true"
android:drawable="@android:color/transparent" />
</selector>
When I press down on a ListViewItem nothing appears.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Alam,使用此代码:
list_selector.xmlgradient_bg.xmlgradient_bg_hover.xml
-
Sheehan
Sheehan Alam, use this code:-
list_selector.xml
gradient_bg.xml
gradient_bg_hover.xml