如何设置 ListView 不可点击 [英] How set ListView not clickable
本文介绍了如何设置 ListView 不可点击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个 ListView
只需要显示数据.
所以我不想让它可点击.
首先,我尝试将 XML 列表视图更改为:
I have this ListView
that just needs to show data.
So I don't want to make it clickable.
First I've tried changing XML listview to:
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:clickable="false" >
但是没有用.
所以为了解决我的问题,我通过代码设置:
But it didn't work.
So to solve my problem I set through code:
list.setSelector(android.R.color.transparent);
但我不敢相信没有更好的解决方案.有什么想法吗?
but I can't believe there's no better solution. Any idea?
推荐答案
这里是,下面是评论:
一种方法是:ListView.setOnClickListener(null);
OR
您可以添加 android:focusable="false"
android:focusableInTouchMode="false"
或
布局中的另一种方式android:listSelector="@android:color/transparent"
干杯.
这篇关于如何设置 ListView 不可点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文