android自定义列表视图背景焦点状态不起作用

前端之家收集整理的这篇文章主要介绍了android自定义列表视图背景焦点状态不起作用前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试为我的ExpandableListView创建自定义背景选择器.它适用于除焦点以外的所有州.我无法确定当前关注哪一行.这是代码

im_selector.xml

@H_301_4@<selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_focused="true" android:drawable="@drawable/list_selector_background_focus" /> <item android:state_pressed="true" android:drawable="@drawable/list_selector_background_pressed" /> <item android:drawable="@drawable/list_bg" /> </selector>

我的列表视图在布局文件

@H_301_4@<ExpandableListView android:id="@+id/android:list" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:scrollbars="horizontal" android:layout_below="@id/top_bar" android:layout_marginBottom="45px" android:divider="#00000000" android:cacheColorHint="#00000000" android:listSelector="@layout/im_selector" android:focusable="true" />

解决方法

当您使用带有列表视图的触摸模式时,“已选择”属性会更改而不是“有针对性”.这就是为什么,对于listviews,你应该在你的选择器中添加像这样的行: @H_301_4@<item android:state_selected="true" android:drawable="@drawable/list_selector_background_focus" />

猜你在找的Android相关文章