English subtitles

← Input Events in Custom Views - Developing Android Apps

Get Embed Code
10 Languages

Showing Revision 15 created 05/24/2016 by Udacity Robot.

  1. The final step in your
    custom view creation
  2. is adding interactivity.
  3. You can listen for user input events
  4. including key presses,
    trackball movement,
  5. and most importantly,
    screen touch events.
  6. All by overriding the
    corresponding event handlers.
  7. Android supports tracking of
    up to 11 individual contact points
  8. in what we like to call,
    jazzhands mode
  9. which enables you
    to complete
  10. complex, multi-finger
    interaction models.
  11. Now, there's really no interaction
    required for a wind gauge,
  12. but you can find out more
    about handling input events
  13. by checking the motion event docs
    or the developer guide
  14. describing how to create your own,
    fully interactive custom views,
  15. both from the instruction notes below.
  16. Now, be careful not to let this
    new found power go to your head.
  17. By definition, your users
    will have never encountered
  18. your brand spanking new control.
  19. So learning how to use it
    is going to add friction
  20. to the use of your app.
  21. At the very least, it should behave
    consistently with the rest of the system
  22. and you should avoid creating
    your own versions of system controls.
  23. If it looks kind of like a button
    and works kind of like a button,
  24. you should probably
    just go ahead and use a button.
  25. But I think this non sequitur
    has gone on long enough.