Disable sweeping items in ListView
I created a ListView in an Activity with a white background. However, if I sweep through the items, their background become black and cover the text. How can I disable it? The listview uses ArrayAdapter to populate it.
Here's my listview xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#F2F2F2">
<LinearLayout android:id="@+id/newEntry"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText android:id="@+id/txtNewItem" android:layout_width="wrap_content" android:layout_height="fill_parent" android:selectAllOnFocus="true"
android:layout_weight="1" android:maxLength="8" android:inputType="numberSigned|numberDecimal"/>
<Button android:id="@+id/btnNewItem" android:text="@string/add_item" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="24sp" />
</LinearLayout>
<LinearLayout android:id="@+id/controlPanel"
android:layout_alignParentBottom="true"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<Button android:id="@+id/btnClearList" android:layout_weight="1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/clear_list"/>
<Button android:id="@+id/btnConfirmList" android:layout_weight="1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/confirm_btn"/>
</LinearLayout>
<ListView android:id="@+id/android:list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="@id/controlPanel"
android:layout_below="@id/newEntry" />
<TextView android:id="@+id/android:empty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/no_items"
android:layout_below="@id/newEntry"
android:textColor="#000000" />
<开发者_运维问答/RelativeLayout>
You can do that by using. Add this line in your ListView in the xml.
android:scrollingCache="false"
This is possibly a ListView background drawing issue. Check out this article for a discussion and a fix.
It's also possible that you are seeing some slight interference between your background color and the default theme (Light or Dark) for the activity. Try changing the theme to the light version (Theme.Light).
精彩评论