取消选择在ListView中选中的项目 [英] Deselect selected item in ListView

查看:103
本文介绍了取消选择在ListView中选中的项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用的ListView 在我的布局是这样的:

I use a ListView in my layout like this:

 <ListView android:id="@+id/list"
              android:layout_width="fill_parent"
              android:layout_gravity="center"
              android:layout_height="match_parent"
              android:layout_weight="0.7"
              android:layout_marginTop="5dp"
              android:orientation="vertical"
              android:layout_centerInParent="true"
              android:divider="@color/dark_grey"
              android:drawSelectorOnTop="false"
              android:focusable="true"
              android:layout_marginBottom="55dp"
              android:cacheColorHint="#00000000"
              android:listSelector="@color/light_grey"
              android:dividerHeight="1px" />

选择器的工作原理很大,但我怎么可以禁用选择?

The selector works great but how can I disable the selector?

我想:

listView.clearChoices();
listView.setSelected();
listView.setSelector();
...

和一些更多的东西,但没有任何工程。任何想法如何,我可以把我的选择的项目恢复正常?不能是复杂的,对吧?

and a few more things but nothing works. Any ideas how I can turn my selected item back to normal? Can't be that complicated, right?

编辑:我需要的程序化解决方案

I need a programmatical solution!

谢谢!

推荐答案

呼叫 requestLayout()的ListView clearChoices()。它将工作。

这篇关于取消选择在ListView中选中的项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆