ListView元素 - 蓝色突出显示

问题描述:

当我单击或按住ListView中的某个项目时,它会以蓝色突出显示。我该如何禁用它?我不想要任何亮点。ListView元素 - 蓝色突出显示

我包含.xml文件的ListView:

<?xml version="1.0" encoding="utf-8"?> 
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/TableLayout1" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" > 

    <ListView 
     android:id="@+id/listView1" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_marginTop="10dp" > 
    </ListView> 

</TableLayout> 

的.xml的ListView的项目:

<?xml version="1.0" encoding="utf-8"?> 
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" > 

    <TableRow 
     android:id="@+id/tableRow1" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="5dp" 
     android:background="#EC7703" 
     android:padding="3dp" > 

     <TextView 
      android:id="@+id/lessonHoursTitle" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="7dp" 
      android:layout_weight="1" 
      android:text="8.00-9.30" 
      android:textSize="16sp" 
      android:textStyle="bold" /> 

     <TextView 
      android:id="@+id/lessonTitle" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="2" 
      android:text="Mechanika ogólna" 
      android:textSize="18sp" /> 
    </TableRow> 
</TableLayout> 

我试图把这个在ListView控件,但它不工作:

android:clickable="false" 
android:contextClickable="false" 
android:focusable="false" 
android:focusableInTouchMode="false" 
android:longClickable="false" 

在ListView元素上,您需要重写listSelector属性。

事情是这样的:

<ListView 
    android:id="@+id/listView1" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:listSelector="@android:color/transparent" 
    android:layout_marginTop="10dp" > 
</ListView> 

添加到您的ListView XML:

<ListView 
     android:listSelector="@android:color/transparent" 
     android:cacheColorHint="@android:color/transparent" 
     />