2011年11月8日 星期二

[Android] Action Bar - (1)

[Android 3.0]
  • A replacement for the traditional title bar at the top of the activity window. Includes:
    • The application logo in the left corner.
    • Provides a new interface for items in the Options Menu.
  • Can provide:
    • Action items
      • Equal to option menu items.
      • Using android:showAsAction menu item xml attribute with a value of "ifRoom"
      • When there's enough room
        • The menu item appears directly in the Action Bar.
      • Otherwise
        • The item is placed in the overflow menu, revealed by the menu icon on the right side of the Action Bar.
      • By default all items from the Options Menu are placed in the overflow menu.
        • The user can open by touching the menu icon on the right side of the Action Bar.
        • However, you can place select menu items directly in the Action Bar as "action items," for instant access
    • Action view
      • Replace an action item with a widget, ex: search box.
      • Using android:actionViewLayout(android:actionLayout?) attribute with a layout resource or the android:actionViewClass attribute with the class name of a widget.
      • You must also declare the android:showAsAction attribute so that the item appears in the Action Bar.
      • If there's not enough room in the Action Bar does not show the widget.
    • Add an action to the application logo and replace it with a custom logo
      • The application logo is automatically assigned the android.R.id.home ID, which the system delivers to your activity's onOptionsItemSelected() callback when touched.
      • Simply respond to this ID in your callback method to perform an action such as go to your application's "home" activity.
      • To replace the icon with a logo.
        • Specify your application logo in the manifest file with the android:logo attribute, then call setDisplayUseLogoEnabled(true) in your activity.
    • Add breadcrumbs to navigate backward through the back stack of fragments.
    • Add tabs or a drop-down list to navigate through fragments.
    • Customize the Action Bar with themes and backgrounds.


Summary
  • action items = options menu = overflow action items (ifRoom)
  • context menu: showing after long press
    • Displayed when the user performs a "right-click" on a PC.
    • 需覆寫 onCreateContextMenu()onContextItemSelected()
  • action view: widget(search box)


By the way

沒有留言:

張貼留言