Android Graphical User Interface

Goal

  • Familiarize with the main types of GUI components
  • Concepts:
  1. Layouts
  2. Widgets
  3. Menus

View Hierarchy

  • All the views in a window are arranged in a tree
  • You show the tree by calling setContentView(rootNode) in the activity

Layout

  • Defines how elements are positioned relative to each other (next to each other, under each other, in a table, grid, etc.)
  • Can have a different layouts for each ViewGroup

Widgets

  • All are View objects
  • Examples:
    1. TextFields
    2. EditFields
    3. Buttons
    4. Checkboxes
    5. RadioButtons
    6. etc.

UI Events

  • Usually handled by defining a Listener of the form  On<something>Listener and register it with the View
  • For example:
    1. OnClickListener() for handling clicks on Buttons or Lists
    2. OnTouchListener() for handling touches
    3. OnKeyListener() for handling key presses
  • Alternatively, Override an existing callback if we implemented our own class extending View

 

Menus

Options Menu

 

Context Menu

 

Sub-menu

Be the first to comment

Leave a Reply

Your email address will not be published.


*