• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps newb - Highlight of selected item in ListView

mjdenham

Lurker
Hi,

I have a set of items in a ListView and am testing using the Android emulator.

When I click a list item with my mouse the item background flashes yellow and then goes black when I release the mouse button. If I then scroll up and down using arrow keys the selected items background turns orange and remains orange.

This highlighting behaviour seems peculiar. Is this correct? I did originally expect the highlight to persist after clicking an item and the highlight after click and arrow to be the same colour.

Here is a basic test layout I used:
Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
	<ListView android:id="@+id/ListView01" 
		android:layout_width="fill_parent" 
		android:layout_height="wrap_content"
		android:entries="@array/animals"/>
</LinearLayout>
Thanks
Martin
 
Yes, Android operates in one of two modes:

1. Touch mode, which is activated by touchscreen events, where your list item doesn't need to be highlighted as it is pressed.

2. Trackpad mode, activated by... the trackpad, where obviously you need to highlight what is selected.

If you want users to be able to select an item (i.e. multiple files to delete) rather than the trackpad mode select to err, select, you would use a checkbox. Using that, the user would press the checkbox, or select it with the trackpad, and pressing the trackpad would toggle the checkbox.

More info here.
 
Back
Top Bottom