Android setMultiChoiceModeListener和所选项目

时间:2015-04-19 19:12:29

标签: android android-listview

使用setSelected时,onItemClick时我应该使用setMultiChoiceModeListener吗?

2 个答案:

答案 0 :(得分:2)

不会改变背景颜色。列表项的根元素是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>

答案 1 :(得分:1)

不,你不应该。

当您输入Multi Choice Mode时(通常通过长按单击列表项触发)主要的onItemClick侦听器将被覆盖,并且所有将被按下的项目将被标记为已选中。