newb - Highlight of selected item in ListView

Discussion in 'Application Development' started by mjdenham, Jun 4, 2010.

  1. mjdenham

    mjdenham New Member
    5

    Jun 4, 2010
    3
    0
    5
    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 (Text):
    1.  
    2. <?xml version="1.0" encoding="utf-8"?>
    3. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    4.     android:orientation="vertical"
    5.     android:layout_width="fill_parent"
    6.     android:layout_height="fill_parent"
    7.     >
    8.     <ListView android:id="@+id/ListView01"
    9.         android:layout_width="fill_parent"
    10.         android:layout_height="wrap_content"
    11.         android:entries="@array/animals"/>
    12. </LinearLayout>
    13.  
    Thanks
    Martin
     

    Advertisement

  2. Doc Savage

    Doc Savage Well-Known Member
    15

    Jan 13, 2010
    45
    0
    15
    Mission Control
    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.
     

Share This Page

Loading...