37

Can anyone explain (or point me to a link that explains) the difference between state_activated, state_selected, state_pressed, and state_focused for ListView items? Are they all valid states for ListViews? Does it matter if touch or a keyboard are being used? This link no longer seems to be valid.

Many thanks!

Melanie
  • 3,021
  • 6
  • 38
  • 56
  • 3
    The new link is here: http://developer.android.com/reference/android/graphics/drawable/StateListDrawable.html – Gary S. Sep 02 '14 at 23:26

1 Answers1

70
  • state_selected is used when an item is selected using a keyboard/dpad/trackball/etc.
  • state_activated is used when View.setActivated(true) is called. This is used for "persistent selection" (see Settings on tablet for instance)
  • state_pressed is used when the user is pressing the item either through touch or a keyboard or a mouse
  • state_focused is used if the item is marked focusable and it receives focus either through the user of a keyboard/dpad/trackball/etc. or if the item is focusable in touch mode
Romain Guy
  • 97,993
  • 18
  • 219
  • 200
  • 16
    difference between state_activated and state_active ? – raj May 01 '13 at 22:28
  • 2
    Does "state_activated" get used on other cases? for example, what is used when making a multiple-selection on a listView ? What is the difference between using "state_activated" and "state_checked" ? – android developer May 05 '14 at 19:42
  • I was wondering, I am going to be using activated for highlighting one item in a list view, but does it set the activate for other list items to false ... if not do either of these do that so I do not have to find the other activated child item and set activation to false? – Lion789 Mar 20 '16 at 17:52