如果我在ListView中选择一行,它会突出显示,但每当我进入MultipleSelection模式(onLongClick,#selected rows,Contextual Action Bar)时,我选择的其他行都不会突出显示 BUT < / strong>根据CAB选择,&#34; 3选择行&#34;。
main.xml中
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
...
>
<HorizontalScrollView
...
>
<LinearLayout
...
>
<TableLayout
...
>
<TableRow
...
>
<TextView
...
/>
<TextView
...
/>
</TableRow>
</TableLayout>
<ListView
android:id="@+id/db_op_data_grid"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:listSelector="@drawable/rowselector"
android:divider="@android:color/transparent" />
</LinearLayout>
</HorizontalScrollView>
</FrameLayout>
rowselector.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true"
android:drawable="@drawable/select_button_selectable" />
<!-- focused -->
<item android:state_focused="true" android:state_pressed="true"
android:drawable="@drawable/select_button_selectable" />
<!-- focused and pressed-->
<item android:state_pressed="true"
android:drawable="@drawable/select_button_selected" />
<!-- pressed -->
<item android:drawable="@drawable/select_button_selectable" />
<!-- default -->
</selector>
编辑:图片如下所示: Selected Rows but not Highlighted
答案 0 :(得分:0)
您需要在选择器中添加state_selected
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/select_button_selectable" android:state_focused="true" />
<!-- focused -->
<item android:drawable="@drawable/select_button_selectable" android:state_focused="true" android:state_pressed="true" />
<!-- focused and pressed-->
<item android:drawable="@drawable/select_button_selected" android:state_pressed="true" />
<!-- pressed -->
<item android:drawable="@drawable/select_button_selected" android:state_selected="true" />
<!-- selected (ADD THIS) -->
<item android:drawable="@drawable/select_button_selectable" />
<!-- default -->
</selector>