ListView 元素 - 蓝色高亮
ListView element - blue highlight
当我单击或按住 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"
/>
当我单击或按住 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"
/>