2015-09-28 115 views
1

當我單擊或按住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" 

回答

2

在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> 
1

添加到您的ListView XML:

<ListView 
     android:listSelector="@android:color/transparent" 
     android:cacheColorHint="@android:color/transparent" 
     /> 
相關問題