1. Are you ready for the Galaxy S20? Here is everything we know so far!

newb - Highlight of selected item in ListView

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

  1. mjdenham

    mjdenham Lurker
    Thread Starter

    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
     


  2. Doc Savage

    Doc Savage Newbie

    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.
     
Loading...
Similar Threads - newb Highlight selected
  1. Tristan Raghnall
    Replies:
    1
    Views:
    592
  2. VnBrew
    Replies:
    0
    Views:
    58
  3. Papamalo
    Replies:
    1
    Views:
    363
  4. Lu D
    Replies:
    4
    Views:
    2,758
  5. indratiny
    Replies:
    0
    Views:
    267
  6. Maxbrady
    Replies:
    2
    Views:
    301
  7. CharlesLewis
    Replies:
    2
    Views:
    388
  8. DaveHorne
    Replies:
    0
    Views:
    385
  9. astadel
    Replies:
    6
    Views:
    462
  10. thisismynamemane123
    Replies:
    1
    Views:
    978

Share This Page

Loading...