如何设置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" >
但没有奏效。
因此,要解决我的问题,我通过code设置:
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(空);
或
One way to do so is:
ListView.setOnClickListener(null);
OR
您可以添加机器人:可调焦=假
安卓focusableInTouchMode =假
或
另一种方式布局安卓listSelector =@机器人:彩色/透明
干杯。
这篇关于如何设置ListView控件无法点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文