0
如果我在ListView中選擇了一行,它會突出顯示,但每當我進入MultipleSelection模式(onLongClick,#選定行,上下文操作欄)時,我選擇的其他行都不會仍然突出顯示但是根據CAB進行選擇,因爲它顯示「3個選定的行」。ListView上的其他選定行被選中但未突出顯示
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
不工作。這幾天我一直在絞盡腦汁。 – ThatGuyWhoRushesToTheFrontline
如果它在xml中不適用於'state_selected',那麼這意味着視圖的選擇陳述沒有被設置爲true。你可以嘗試在適配器內手動設置'setSelected(true)'onItemClickListener' – adnanyousafch
我認爲state_selected可以工作,但應用程序不記得我按下了它。我使用的是data_grid.setMultiChoiceModeListener(新的AbsListView.MultiChoiceModeListener() – ThatGuyWhoRushesToTheFrontline