大家好我怎么能突出显示android中水平列表视图中的项目。我已经实现了突出显示但它不会在水平列表视图中保留。我认为这是水平列表视图的问题,因为突出显示在简单列表视图中工作正常。任何人都可以帮我解决我的问题。提前谢谢。
这是我的横向列表视图:
<com.extraslice.gmobile.HorizontalListView
android:id="@+id/listViewadmin_main"
android:layout_width="match_parent"
android:layout_height="180dp"
android:cacheColorHint="#000000"
android:choiceMode="singleChoice"
android:dividerHeight="1dip" />
list_item_background.xml是:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false" android:state_focused="false" android:state_selected="false"
android:drawable="@drawable/org_blue" />
<item android:state_pressed="true"
android:drawable="@drawable/yellow_orgs" />
<item android:state_focused="true" android:state_selected="true"
android:drawable="@drawable/yellow_orgs" android:state_activated="true"/>
</selector>
我在listview项目中包含了list_item_background.xml,如:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="250dp"
android:id="@+id/agent_layout"
android:layout_height="200dp"
android:background="@drawable/list_item_background"
android:orientation="vertical" />
请给我一个解决方案,以突出显示水平列表视图。
答案 0 :(得分:0)
不是将此应用于模板,而是尝试将应用选择器应用于listview
<com.extraslice.gmobile.HorizontalListView
android:id="@+id/listViewadmin_main"
android:layout_width="match_parent"
android:layout_height="180dp"
android:cacheColorHint="#000000"
android:choiceMode="singleChoice"
android:listSelector="@drawable/list_item_background"
android:dividerHeight="1dip" />
希望它可能有所帮助。