Android setMultiChoiceModeListener 和选择的项目
Android setMultiChoiceModeListener and selected item
我应该在 onItemClick
使用 setMultiChoiceModeListener
时使用 setSelected
吗?
不,你不应该。
当您输入 Multi Choice Mode
时(通常是通过长按列表项触发)主 onItemClick 侦听器将被覆盖,所有将被按下的项目将被标记为已选中。
不会改变背景颜色。列表项的根元素是 RelativeLayout (在我的例子中)?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?android:attr/activatedBackgroundIndicator">
<ListView
android:id="@+id/listView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="#ebebeb"
android:dividerHeight="1dip"/>
</RelativeLayout>
我应该在 onItemClick
使用 setMultiChoiceModeListener
时使用 setSelected
吗?
不,你不应该。
当您输入 Multi Choice Mode
时(通常是通过长按列表项触发)主 onItemClick 侦听器将被覆盖,所有将被按下的项目将被标记为已选中。
不会改变背景颜色。列表项的根元素是 RelativeLayout (在我的例子中)?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?android:attr/activatedBackgroundIndicator">
<ListView
android:id="@+id/listView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="#ebebeb"
android:dividerHeight="1dip"/>
</RelativeLayout>