newb - Highlight of selected item in ListView


Last Updated:

  1. mjdenham

    mjdenham New Member This Topic's Starter

    Joined:
    Jun 4, 2010
    Messages:
    3
    Likes Received:
    0
    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

    Joined:
    Jan 13, 2010
    Messages:
    45
    Likes Received:
    0
    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...