如何设置ListView控件无法点击控件、如何设置、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 t...

我有这样的的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 =@机器人:彩色/透明

干杯。

阅读全文

相关推荐

最新文章