--- /dev/null
+/*\r
+ * Copyright (C) 2010 The Android Open Source Project\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package com.actionbarsherlock.app;\r
+\r
+import android.content.Context;\r
+import android.graphics.drawable.Drawable;\r
+import android.support.v4.app.FragmentTransaction;\r
+import android.util.AttributeSet;\r
+import android.view.Gravity;\r
+import android.view.View;\r
+import android.view.ViewDebug;\r
+import android.view.ViewGroup;\r
+import android.view.ViewGroup.MarginLayoutParams;\r
+import android.widget.SpinnerAdapter;\r
+\r
+/**\r
+ * A window feature at the top of the activity that may display the activity title, navigation\r
+ * modes, and other interactive items.\r
+ * <p>Beginning with Android 3.0 (API level 11), the action bar appears at the top of an\r
+ * activity's window when the activity uses the system's {@link\r
+ * android.R.style#Theme_Holo Holo} theme (or one of its descendant themes), which is the default.\r
+ * You may otherwise add the action bar by calling {@link\r
+ * android.view.Window#requestFeature requestFeature(FEATURE_ACTION_BAR)} or by declaring it in a\r
+ * custom theme with the {@link android.R.styleable#Theme_windowActionBar windowActionBar} property.\r
+ * <p>By default, the action bar shows the application icon on\r
+ * the left, followed by the activity title. If your activity has an options menu, you can make\r
+ * select items accessible directly from the action bar as "action items". You can also\r
+ * modify various characteristics of the action bar or remove it completely.</p>\r
+ * <p>From your activity, you can retrieve an instance of {@link ActionBar} by calling {@link\r
+ * android.app.Activity#getActionBar getActionBar()}.</p>\r
+ * <p>In some cases, the action bar may be overlayed by another bar that enables contextual actions,\r
+ * using an {@link android.view.ActionMode}. For example, when the user selects one or more items in\r
+ * your activity, you can enable an action mode that offers actions specific to the selected\r
+ * items, with a UI that temporarily replaces the action bar. Although the UI may occupy the\r
+ * same space, the {@link android.view.ActionMode} APIs are distinct and independent from those for\r
+ * {@link ActionBar}.\r
+ * <div class="special reference">\r
+ * <h3>Developer Guides</h3>\r
+ * <p>For information about how to use the action bar, including how to add action items, navigation\r
+ * modes and more, read the <a href="{@docRoot}guide/topics/ui/actionbar.html">Action\r
+ * Bar</a> developer guide.</p>\r
+ * </div>\r
+ */\r
+public abstract class ActionBar {\r
+ /**\r
+ * Standard navigation mode. Consists of either a logo or icon\r
+ * and title text with an optional subtitle. Clicking any of these elements\r
+ * will dispatch onOptionsItemSelected to the host Activity with\r
+ * a MenuItem with item ID android.R.id.home.\r
+ */\r
+ public static final int NAVIGATION_MODE_STANDARD = android.app.ActionBar.NAVIGATION_MODE_STANDARD;\r
+\r
+ /**\r
+ * List navigation mode. Instead of static title text this mode\r
+ * presents a list menu for navigation within the activity.\r
+ * e.g. this might be presented to the user as a dropdown list.\r
+ */\r
+ public static final int NAVIGATION_MODE_LIST = android.app.ActionBar.NAVIGATION_MODE_LIST;\r
+\r
+ /**\r
+ * Tab navigation mode. Instead of static title text this mode\r
+ * presents a series of tabs for navigation within the activity.\r
+ */\r
+ public static final int NAVIGATION_MODE_TABS = android.app.ActionBar.NAVIGATION_MODE_TABS;\r
+\r
+ /**\r
+ * Use logo instead of icon if available. This flag will cause appropriate\r
+ * navigation modes to use a wider logo in place of the standard icon.\r
+ *\r
+ * @see #setDisplayOptions(int)\r
+ * @see #setDisplayOptions(int, int)\r
+ */\r
+ public static final int DISPLAY_USE_LOGO = android.app.ActionBar.DISPLAY_USE_LOGO;\r
+\r
+ /**\r
+ * Show 'home' elements in this action bar, leaving more space for other\r
+ * navigation elements. This includes logo and icon.\r
+ *\r
+ * @see #setDisplayOptions(int)\r
+ * @see #setDisplayOptions(int, int)\r
+ */\r
+ public static final int DISPLAY_SHOW_HOME = android.app.ActionBar.DISPLAY_SHOW_HOME;\r
+\r
+ /**\r
+ * Display the 'home' element such that it appears as an 'up' affordance.\r
+ * e.g. show an arrow to the left indicating the action that will be taken.\r
+ *\r
+ * Set this flag if selecting the 'home' button in the action bar to return\r
+ * up by a single level in your UI rather than back to the top level or front page.\r
+ *\r
+ * <p>Setting this option will implicitly enable interaction with the home/up\r
+ * button. See {@link #setHomeButtonEnabled(boolean)}.\r
+ *\r
+ * @see #setDisplayOptions(int)\r
+ * @see #setDisplayOptions(int, int)\r
+ */\r
+ public static final int DISPLAY_HOME_AS_UP = android.app.ActionBar.DISPLAY_HOME_AS_UP;\r
+\r
+ /**\r
+ * Show the activity title and subtitle, if present.\r
+ *\r
+ * @see #setTitle(CharSequence)\r
+ * @see #setTitle(int)\r
+ * @see #setSubtitle(CharSequence)\r
+ * @see #setSubtitle(int)\r
+ * @see #setDisplayOptions(int)\r
+ * @see #setDisplayOptions(int, int)\r
+ */\r
+ public static final int DISPLAY_SHOW_TITLE = android.app.ActionBar.DISPLAY_SHOW_TITLE;\r
+\r
+ /**\r
+ * Show the custom view if one has been set.\r
+ * @see #setCustomView(View)\r
+ * @see #setDisplayOptions(int)\r
+ * @see #setDisplayOptions(int, int)\r
+ */\r
+ public static final int DISPLAY_SHOW_CUSTOM = android.app.ActionBar.DISPLAY_SHOW_CUSTOM;\r
+\r
+ /**\r
+ * Set the action bar into custom navigation mode, supplying a view\r
+ * for custom navigation.\r
+ *\r
+ * Custom navigation views appear between the application icon and\r
+ * any action buttons and may use any space available there. Common\r
+ * use cases for custom navigation views might include an auto-suggesting\r
+ * address bar for a browser or other navigation mechanisms that do not\r
+ * translate well to provided navigation modes.\r
+ *\r
+ * @param view Custom navigation view to place in the ActionBar.\r
+ */\r
+ public abstract void setCustomView(View view);\r
+\r
+ /**\r
+ * Set the action bar into custom navigation mode, supplying a view\r
+ * for custom navigation.\r
+ *\r
+ * <p>Custom navigation views appear between the application icon and\r
+ * any action buttons and may use any space available there. Common\r
+ * use cases for custom navigation views might include an auto-suggesting\r
+ * address bar for a browser or other navigation mechanisms that do not\r
+ * translate well to provided navigation modes.</p>\r
+ *\r
+ * <p>The display option {@link #DISPLAY_SHOW_CUSTOM} must be set for\r
+ * the custom view to be displayed.</p>\r
+ *\r
+ * @param view Custom navigation view to place in the ActionBar.\r
+ * @param layoutParams How this custom view should layout in the bar.\r
+ *\r
+ * @see #setDisplayOptions(int, int)\r
+ */\r
+ public abstract void setCustomView(View view, LayoutParams layoutParams);\r
+\r
+ /**\r
+ * Set the action bar into custom navigation mode, supplying a view\r
+ * for custom navigation.\r
+ *\r
+ * <p>Custom navigation views appear between the application icon and\r
+ * any action buttons and may use any space available there. Common\r
+ * use cases for custom navigation views might include an auto-suggesting\r
+ * address bar for a browser or other navigation mechanisms that do not\r
+ * translate well to provided navigation modes.</p>\r
+ *\r
+ * <p>The display option {@link #DISPLAY_SHOW_CUSTOM} must be set for\r
+ * the custom view to be displayed.</p>\r
+ *\r
+ * @param resId Resource ID of a layout to inflate into the ActionBar.\r
+ *\r
+ * @see #setDisplayOptions(int, int)\r
+ */\r
+ public abstract void setCustomView(int resId);\r
+\r
+ /**\r
+ * Set the icon to display in the 'home' section of the action bar.\r
+ * The action bar will use an icon specified by its style or the\r
+ * activity icon by default.\r
+ *\r
+ * Whether the home section shows an icon or logo is controlled\r
+ * by the display option {@link #DISPLAY_USE_LOGO}.\r
+ *\r
+ * @param resId Resource ID of a drawable to show as an icon.\r
+ *\r
+ * @see #setDisplayUseLogoEnabled(boolean)\r
+ * @see #setDisplayShowHomeEnabled(boolean)\r
+ */\r
+ public abstract void setIcon(int resId);\r
+\r
+ /**\r
+ * Set the icon to display in the 'home' section of the action bar.\r
+ * The action bar will use an icon specified by its style or the\r
+ * activity icon by default.\r
+ *\r
+ * Whether the home section shows an icon or logo is controlled\r
+ * by the display option {@link #DISPLAY_USE_LOGO}.\r
+ *\r
+ * @param icon Drawable to show as an icon.\r
+ *\r
+ * @see #setDisplayUseLogoEnabled(boolean)\r
+ * @see #setDisplayShowHomeEnabled(boolean)\r
+ */\r
+ public abstract void setIcon(Drawable icon);\r
+\r
+ /**\r
+ * Set the logo to display in the 'home' section of the action bar.\r
+ * The action bar will use a logo specified by its style or the\r
+ * activity logo by default.\r
+ *\r
+ * Whether the home section shows an icon or logo is controlled\r
+ * by the display option {@link #DISPLAY_USE_LOGO}.\r
+ *\r
+ * @param resId Resource ID of a drawable to show as a logo.\r
+ *\r
+ * @see #setDisplayUseLogoEnabled(boolean)\r
+ * @see #setDisplayShowHomeEnabled(boolean)\r
+ */\r
+ public abstract void setLogo(int resId);\r
+\r
+ /**\r
+ * Set the logo to display in the 'home' section of the action bar.\r
+ * The action bar will use a logo specified by its style or the\r
+ * activity logo by default.\r
+ *\r
+ * Whether the home section shows an icon or logo is controlled\r
+ * by the display option {@link #DISPLAY_USE_LOGO}.\r
+ *\r
+ * @param logo Drawable to show as a logo.\r
+ *\r
+ * @see #setDisplayUseLogoEnabled(boolean)\r
+ * @see #setDisplayShowHomeEnabled(boolean)\r
+ */\r
+ public abstract void setLogo(Drawable logo);\r
+\r
+ /**\r
+ * Set the adapter and navigation callback for list navigation mode.\r
+ *\r
+ * The supplied adapter will provide views for the expanded list as well as\r
+ * the currently selected item. (These may be displayed differently.)\r
+ *\r
+ * The supplied OnNavigationListener will alert the application when the user\r
+ * changes the current list selection.\r
+ *\r
+ * @param adapter An adapter that will provide views both to display\r
+ * the current navigation selection and populate views\r
+ * within the dropdown navigation menu.\r
+ * @param callback An OnNavigationListener that will receive events when the user\r
+ * selects a navigation item.\r
+ */\r
+ public abstract void setListNavigationCallbacks(SpinnerAdapter adapter,\r
+ OnNavigationListener callback);\r
+\r
+ /**\r
+ * Set the selected navigation item in list or tabbed navigation modes.\r
+ *\r
+ * @param position Position of the item to select.\r
+ */\r
+ public abstract void setSelectedNavigationItem(int position);\r
+\r
+ /**\r
+ * Get the position of the selected navigation item in list or tabbed navigation modes.\r
+ *\r
+ * @return Position of the selected item.\r
+ */\r
+ public abstract int getSelectedNavigationIndex();\r
+\r
+ /**\r
+ * Get the number of navigation items present in the current navigation mode.\r
+ *\r
+ * @return Number of navigation items.\r
+ */\r
+ public abstract int getNavigationItemCount();\r
+\r
+ /**\r
+ * Set the action bar's title. This will only be displayed if\r
+ * {@link #DISPLAY_SHOW_TITLE} is set.\r
+ *\r
+ * @param title Title to set\r
+ *\r
+ * @see #setTitle(int)\r
+ * @see #setDisplayOptions(int, int)\r
+ */\r
+ public abstract void setTitle(CharSequence title);\r
+\r
+ /**\r
+ * Set the action bar's title. This will only be displayed if\r
+ * {@link #DISPLAY_SHOW_TITLE} is set.\r
+ *\r
+ * @param resId Resource ID of title string to set\r
+ *\r
+ * @see #setTitle(CharSequence)\r
+ * @see #setDisplayOptions(int, int)\r
+ */\r
+ public abstract void setTitle(int resId);\r
+\r
+ /**\r
+ * Set the action bar's subtitle. This will only be displayed if\r
+ * {@link #DISPLAY_SHOW_TITLE} is set. Set to null to disable the\r
+ * subtitle entirely.\r
+ *\r
+ * @param subtitle Subtitle to set\r
+ *\r
+ * @see #setSubtitle(int)\r
+ * @see #setDisplayOptions(int, int)\r
+ */\r
+ public abstract void setSubtitle(CharSequence subtitle);\r
+\r
+ /**\r
+ * Set the action bar's subtitle. This will only be displayed if\r
+ * {@link #DISPLAY_SHOW_TITLE} is set.\r
+ *\r
+ * @param resId Resource ID of subtitle string to set\r
+ *\r
+ * @see #setSubtitle(CharSequence)\r
+ * @see #setDisplayOptions(int, int)\r
+ */\r
+ public abstract void setSubtitle(int resId);\r
+\r
+ /**\r
+ * Set display options. This changes all display option bits at once. To change\r
+ * a limited subset of display options, see {@link #setDisplayOptions(int, int)}.\r
+ *\r
+ * @param options A combination of the bits defined by the DISPLAY_ constants\r
+ * defined in ActionBar.\r
+ */\r
+ public abstract void setDisplayOptions(int options);\r
+\r
+ /**\r
+ * Set selected display options. Only the options specified by mask will be changed.\r
+ * To change all display option bits at once, see {@link #setDisplayOptions(int)}.\r
+ *\r
+ * <p>Example: setDisplayOptions(0, DISPLAY_SHOW_HOME) will disable the\r
+ * {@link #DISPLAY_SHOW_HOME} option.\r
+ * setDisplayOptions(DISPLAY_SHOW_HOME, DISPLAY_SHOW_HOME | DISPLAY_USE_LOGO)\r
+ * will enable {@link #DISPLAY_SHOW_HOME} and disable {@link #DISPLAY_USE_LOGO}.\r
+ *\r
+ * @param options A combination of the bits defined by the DISPLAY_ constants\r
+ * defined in ActionBar.\r
+ * @param mask A bit mask declaring which display options should be changed.\r
+ */\r
+ public abstract void setDisplayOptions(int options, int mask);\r
+\r
+ /**\r
+ * Set whether to display the activity logo rather than the activity icon.\r
+ * A logo is often a wider, more detailed image.\r
+ *\r
+ * <p>To set several display options at once, see the setDisplayOptions methods.\r
+ *\r
+ * @param useLogo true to use the activity logo, false to use the activity icon.\r
+ *\r
+ * @see #setDisplayOptions(int)\r
+ * @see #setDisplayOptions(int, int)\r
+ */\r
+ public abstract void setDisplayUseLogoEnabled(boolean useLogo);\r
+\r
+ /**\r
+ * Set whether to include the application home affordance in the action bar.\r
+ * Home is presented as either an activity icon or logo.\r
+ *\r
+ * <p>To set several display options at once, see the setDisplayOptions methods.\r
+ *\r
+ * @param showHome true to show home, false otherwise.\r
+ *\r
+ * @see #setDisplayOptions(int)\r
+ * @see #setDisplayOptions(int, int)\r
+ */\r
+ public abstract void setDisplayShowHomeEnabled(boolean showHome);\r
+\r
+ /**\r
+ * Set whether home should be displayed as an "up" affordance.\r
+ * Set this to true if selecting "home" returns up by a single level in your UI\r
+ * rather than back to the top level or front page.\r
+ *\r
+ * <p>To set several display options at once, see the setDisplayOptions methods.\r
+ *\r
+ * @param showHomeAsUp true to show the user that selecting home will return one\r
+ * level up rather than to the top level of the app.\r
+ *\r
+ * @see #setDisplayOptions(int)\r
+ * @see #setDisplayOptions(int, int)\r
+ */\r
+ public abstract void setDisplayHomeAsUpEnabled(boolean showHomeAsUp);\r
+\r
+ /**\r
+ * Set whether an activity title/subtitle should be displayed.\r
+ *\r
+ * <p>To set several display options at once, see the setDisplayOptions methods.\r
+ *\r
+ * @param showTitle true to display a title/subtitle if present.\r
+ *\r
+ * @see #setDisplayOptions(int)\r
+ * @see #setDisplayOptions(int, int)\r
+ */\r
+ public abstract void setDisplayShowTitleEnabled(boolean showTitle);\r
+\r
+ /**\r
+ * Set whether a custom view should be displayed, if set.\r
+ *\r
+ * <p>To set several display options at once, see the setDisplayOptions methods.\r
+ *\r
+ * @param showCustom true if the currently set custom view should be displayed, false otherwise.\r
+ *\r
+ * @see #setDisplayOptions(int)\r
+ * @see #setDisplayOptions(int, int)\r
+ */\r
+ public abstract void setDisplayShowCustomEnabled(boolean showCustom);\r
+\r
+ /**\r
+ * Set the ActionBar's background. This will be used for the primary\r
+ * action bar.\r
+ *\r
+ * @param d Background drawable\r
+ * @see #setStackedBackgroundDrawable(Drawable)\r
+ * @see #setSplitBackgroundDrawable(Drawable)\r
+ */\r
+ public abstract void setBackgroundDrawable(Drawable d);\r
+\r
+ /**\r
+ * Set the ActionBar's stacked background. This will appear\r
+ * in the second row/stacked bar on some devices and configurations.\r
+ *\r
+ * @param d Background drawable for the stacked row\r
+ */\r
+ public void setStackedBackgroundDrawable(Drawable d) { }\r
+\r
+ /**\r
+ * Set the ActionBar's split background. This will appear in\r
+ * the split action bar containing menu-provided action buttons\r
+ * on some devices and configurations.\r
+ * <p>You can enable split action bar with {@link android.R.attr#uiOptions}\r
+ *\r
+ * @param d Background drawable for the split bar\r
+ */\r
+ public void setSplitBackgroundDrawable(Drawable d) { }\r
+\r
+ /**\r
+ * @return The current custom view.\r
+ */\r
+ public abstract View getCustomView();\r
+\r
+ /**\r
+ * Returns the current ActionBar title in standard mode.\r
+ * Returns null if {@link #getNavigationMode()} would not return\r
+ * {@link #NAVIGATION_MODE_STANDARD}.\r
+ *\r
+ * @return The current ActionBar title or null.\r
+ */\r
+ public abstract CharSequence getTitle();\r
+\r
+ /**\r
+ * Returns the current ActionBar subtitle in standard mode.\r
+ * Returns null if {@link #getNavigationMode()} would not return\r
+ * {@link #NAVIGATION_MODE_STANDARD}.\r
+ *\r
+ * @return The current ActionBar subtitle or null.\r
+ */\r
+ public abstract CharSequence getSubtitle();\r
+\r
+ /**\r
+ * Returns the current navigation mode. The result will be one of:\r
+ * <ul>\r
+ * <li>{@link #NAVIGATION_MODE_STANDARD}</li>\r
+ * <li>{@link #NAVIGATION_MODE_LIST}</li>\r
+ * <li>{@link #NAVIGATION_MODE_TABS}</li>\r
+ * </ul>\r
+ *\r
+ * @return The current navigation mode.\r
+ */\r
+ public abstract int getNavigationMode();\r
+\r
+ /**\r
+ * Set the current navigation mode.\r
+ *\r
+ * @param mode The new mode to set.\r
+ * @see #NAVIGATION_MODE_STANDARD\r
+ * @see #NAVIGATION_MODE_LIST\r
+ * @see #NAVIGATION_MODE_TABS\r
+ */\r
+ public abstract void setNavigationMode(int mode);\r
+\r
+ /**\r
+ * @return The current set of display options.\r
+ */\r
+ public abstract int getDisplayOptions();\r
+\r
+ /**\r
+ * Create and return a new {@link Tab}.\r
+ * This tab will not be included in the action bar until it is added.\r
+ *\r
+ * <p>Very often tabs will be used to switch between {@link Fragment}\r
+ * objects. Here is a typical implementation of such tabs:</p>\r
+ *\r
+ * {@sample development/samples/ApiDemos/src/com/example/android/apis/app/FragmentTabs.java\r
+ * complete}\r
+ *\r
+ * @return A new Tab\r
+ *\r
+ * @see #addTab(Tab)\r
+ */\r
+ public abstract Tab newTab();\r
+\r
+ /**\r
+ * Add a tab for use in tabbed navigation mode. The tab will be added at the end of the list.\r
+ * If this is the first tab to be added it will become the selected tab.\r
+ *\r
+ * @param tab Tab to add\r
+ */\r
+ public abstract void addTab(Tab tab);\r
+\r
+ /**\r
+ * Add a tab for use in tabbed navigation mode. The tab will be added at the end of the list.\r
+ *\r
+ * @param tab Tab to add\r
+ * @param setSelected True if the added tab should become the selected tab.\r
+ */\r
+ public abstract void addTab(Tab tab, boolean setSelected);\r
+\r
+ /**\r
+ * Add a tab for use in tabbed navigation mode. The tab will be inserted at\r
+ * <code>position</code>. If this is the first tab to be added it will become\r
+ * the selected tab.\r
+ *\r
+ * @param tab The tab to add\r
+ * @param position The new position of the tab\r
+ */\r
+ public abstract void addTab(Tab tab, int position);\r
+\r
+ /**\r
+ * Add a tab for use in tabbed navigation mode. The tab will be insterted at\r
+ * <code>position</code>.\r
+ *\r
+ * @param tab The tab to add\r
+ * @param position The new position of the tab\r
+ * @param setSelected True if the added tab should become the selected tab.\r
+ */\r
+ public abstract void addTab(Tab tab, int position, boolean setSelected);\r
+\r
+ /**\r
+ * Remove a tab from the action bar. If the removed tab was selected it will be deselected\r
+ * and another tab will be selected if present.\r
+ *\r
+ * @param tab The tab to remove\r
+ */\r
+ public abstract void removeTab(Tab tab);\r
+\r
+ /**\r
+ * Remove a tab from the action bar. If the removed tab was selected it will be deselected\r
+ * and another tab will be selected if present.\r
+ *\r
+ * @param position Position of the tab to remove\r
+ */\r
+ public abstract void removeTabAt(int position);\r
+\r
+ /**\r
+ * Remove all tabs from the action bar and deselect the current tab.\r
+ */\r
+ public abstract void removeAllTabs();\r
+\r
+ /**\r
+ * Select the specified tab. If it is not a child of this action bar it will be added.\r
+ *\r
+ * <p>Note: If you want to select by index, use {@link #setSelectedNavigationItem(int)}.</p>\r
+ *\r
+ * @param tab Tab to select\r
+ */\r
+ public abstract void selectTab(Tab tab);\r
+\r
+ /**\r
+ * Returns the currently selected tab if in tabbed navigation mode and there is at least\r
+ * one tab present.\r
+ *\r
+ * @return The currently selected tab or null\r
+ */\r
+ public abstract Tab getSelectedTab();\r
+\r
+ /**\r
+ * Returns the tab at the specified index.\r
+ *\r
+ * @param index Index value in the range 0-get\r
+ * @return\r
+ */\r
+ public abstract Tab getTabAt(int index);\r
+\r
+ /**\r
+ * Returns the number of tabs currently registered with the action bar.\r
+ * @return Tab count\r
+ */\r
+ public abstract int getTabCount();\r
+\r
+ /**\r
+ * Retrieve the current height of the ActionBar.\r
+ *\r
+ * @return The ActionBar's height\r
+ */\r
+ public abstract int getHeight();\r
+\r
+ /**\r
+ * Show the ActionBar if it is not currently showing.\r
+ * If the window hosting the ActionBar does not have the feature\r
+ * {@link Window#FEATURE_ACTION_BAR_OVERLAY} it will resize application\r
+ * content to fit the new space available.\r
+ */\r
+ public abstract void show();\r
+\r
+ /**\r
+ * Hide the ActionBar if it is currently showing.\r
+ * If the window hosting the ActionBar does not have the feature\r
+ * {@link Window#FEATURE_ACTION_BAR_OVERLAY} it will resize application\r
+ * content to fit the new space available.\r
+ */\r
+ public abstract void hide();\r
+\r
+ /**\r
+ * @return <code>true</code> if the ActionBar is showing, <code>false</code> otherwise.\r
+ */\r
+ public abstract boolean isShowing();\r
+\r
+ /**\r
+ * Add a listener that will respond to menu visibility change events.\r
+ *\r
+ * @param listener The new listener to add\r
+ */\r
+ public abstract void addOnMenuVisibilityListener(OnMenuVisibilityListener listener);\r
+\r
+ /**\r
+ * Remove a menu visibility listener. This listener will no longer receive menu\r
+ * visibility change events.\r
+ *\r
+ * @param listener A listener to remove that was previously added\r
+ */\r
+ public abstract void removeOnMenuVisibilityListener(OnMenuVisibilityListener listener);\r
+\r
+ /**\r
+ * Enable or disable the "home" button in the corner of the action bar. (Note that this\r
+ * is the application home/up affordance on the action bar, not the systemwide home\r
+ * button.)\r
+ *\r
+ * <p>This defaults to true for packages targeting < API 14. For packages targeting\r
+ * API 14 or greater, the application should call this method to enable interaction\r
+ * with the home/up affordance.\r
+ *\r
+ * <p>Setting the {@link #DISPLAY_HOME_AS_UP} display option will automatically enable\r
+ * the home button.\r
+ *\r
+ * @param enabled true to enable the home button, false to disable the home button.\r
+ */\r
+ public void setHomeButtonEnabled(boolean enabled) { }\r
+\r
+ /**\r
+ * Returns a {@link Context} with an appropriate theme for creating views that\r
+ * will appear in the action bar. If you are inflating or instantiating custom views\r
+ * that will appear in an action bar, you should use the Context returned by this method.\r
+ * (This includes adapters used for list navigation mode.)\r
+ * This will ensure that views contrast properly against the action bar.\r
+ *\r
+ * @return A themed Context for creating views\r
+ */\r
+ public Context getThemedContext() { return null; }\r
+\r
+ /**\r
+ * Listener interface for ActionBar navigation events.\r
+ */\r
+ public interface OnNavigationListener {\r
+ /**\r
+ * This method is called whenever a navigation item in your action bar\r
+ * is selected.\r
+ *\r
+ * @param itemPosition Position of the item clicked.\r
+ * @param itemId ID of the item clicked.\r
+ * @return True if the event was handled, false otherwise.\r
+ */\r
+ public boolean onNavigationItemSelected(int itemPosition, long itemId);\r
+ }\r
+\r
+ /**\r
+ * Listener for receiving events when action bar menus are shown or hidden.\r
+ */\r
+ public interface OnMenuVisibilityListener {\r
+ /**\r
+ * Called when an action bar menu is shown or hidden. Applications may want to use\r
+ * this to tune auto-hiding behavior for the action bar or pause/resume video playback,\r
+ * gameplay, or other activity within the main content area.\r
+ *\r
+ * @param isVisible True if an action bar menu is now visible, false if no action bar\r
+ * menus are visible.\r
+ */\r
+ public void onMenuVisibilityChanged(boolean isVisible);\r
+ }\r
+\r
+ /**\r
+ * A tab in the action bar.\r
+ *\r
+ * <p>Tabs manage the hiding and showing of {@link Fragment}s.\r
+ */\r
+ public static abstract class Tab {\r
+ /**\r
+ * An invalid position for a tab.\r
+ *\r
+ * @see #getPosition()\r
+ */\r
+ public static final int INVALID_POSITION = -1;\r
+\r
+ /**\r
+ * Return the current position of this tab in the action bar.\r
+ *\r
+ * @return Current position, or {@link #INVALID_POSITION} if this tab is not currently in\r
+ * the action bar.\r
+ */\r
+ public abstract int getPosition();\r
+\r
+ /**\r
+ * Return the icon associated with this tab.\r
+ *\r
+ * @return The tab's icon\r
+ */\r
+ public abstract Drawable getIcon();\r
+\r
+ /**\r
+ * Return the text of this tab.\r
+ *\r
+ * @return The tab's text\r
+ */\r
+ public abstract CharSequence getText();\r
+\r
+ /**\r
+ * Set the icon displayed on this tab.\r
+ *\r
+ * @param icon The drawable to use as an icon\r
+ * @return The current instance for call chaining\r
+ */\r
+ public abstract Tab setIcon(Drawable icon);\r
+\r
+ /**\r
+ * Set the icon displayed on this tab.\r
+ *\r
+ * @param resId Resource ID referring to the drawable to use as an icon\r
+ * @return The current instance for call chaining\r
+ */\r
+ public abstract Tab setIcon(int resId);\r
+\r
+ /**\r
+ * Set the text displayed on this tab. Text may be truncated if there is not\r
+ * room to display the entire string.\r
+ *\r
+ * @param text The text to display\r
+ * @return The current instance for call chaining\r
+ */\r
+ public abstract Tab setText(CharSequence text);\r
+\r
+ /**\r
+ * Set the text displayed on this tab. Text may be truncated if there is not\r
+ * room to display the entire string.\r
+ *\r
+ * @param resId A resource ID referring to the text that should be displayed\r
+ * @return The current instance for call chaining\r
+ */\r
+ public abstract Tab setText(int resId);\r
+\r
+ /**\r
+ * Set a custom view to be used for this tab. This overrides values set by\r
+ * {@link #setText(CharSequence)} and {@link #setIcon(Drawable)}.\r
+ *\r
+ * @param view Custom view to be used as a tab.\r
+ * @return The current instance for call chaining\r
+ */\r
+ public abstract Tab setCustomView(View view);\r
+\r
+ /**\r
+ * Set a custom view to be used for this tab. This overrides values set by\r
+ * {@link #setText(CharSequence)} and {@link #setIcon(Drawable)}.\r
+ *\r
+ * @param layoutResId A layout resource to inflate and use as a custom tab view\r
+ * @return The current instance for call chaining\r
+ */\r
+ public abstract Tab setCustomView(int layoutResId);\r
+\r
+ /**\r
+ * Retrieve a previously set custom view for this tab.\r
+ *\r
+ * @return The custom view set by {@link #setCustomView(View)}.\r
+ */\r
+ public abstract View getCustomView();\r
+\r
+ /**\r
+ * Give this Tab an arbitrary object to hold for later use.\r
+ *\r
+ * @param obj Object to store\r
+ * @return The current instance for call chaining\r
+ */\r
+ public abstract Tab setTag(Object obj);\r
+\r
+ /**\r
+ * @return This Tab's tag object.\r
+ */\r
+ public abstract Object getTag();\r
+\r
+ /**\r
+ * Set the {@link TabListener} that will handle switching to and from this tab.\r
+ * All tabs must have a TabListener set before being added to the ActionBar.\r
+ *\r
+ * @param listener Listener to handle tab selection events\r
+ * @return The current instance for call chaining\r
+ */\r
+ public abstract Tab setTabListener(TabListener listener);\r
+\r
+ /**\r
+ * Select this tab. Only valid if the tab has been added to the action bar.\r
+ */\r
+ public abstract void select();\r
+\r
+ /**\r
+ * Set a description of this tab's content for use in accessibility support.\r
+ * If no content description is provided the title will be used.\r
+ *\r
+ * @param resId A resource ID referring to the description text\r
+ * @return The current instance for call chaining\r
+ * @see #setContentDescription(CharSequence)\r
+ * @see #getContentDescription()\r
+ */\r
+ public abstract Tab setContentDescription(int resId);\r
+\r
+ /**\r
+ * Set a description of this tab's content for use in accessibility support.\r
+ * If no content description is provided the title will be used.\r
+ *\r
+ * @param contentDesc Description of this tab's content\r
+ * @return The current instance for call chaining\r
+ * @see #setContentDescription(int)\r
+ * @see #getContentDescription()\r
+ */\r
+ public abstract Tab setContentDescription(CharSequence contentDesc);\r
+\r
+ /**\r
+ * Gets a brief description of this tab's content for use in accessibility support.\r
+ *\r
+ * @return Description of this tab's content\r
+ * @see #setContentDescription(CharSequence)\r
+ * @see #setContentDescription(int)\r
+ */\r
+ public abstract CharSequence getContentDescription();\r
+ }\r
+\r
+ /**\r
+ * Callback interface invoked when a tab is focused, unfocused, added, or removed.\r
+ */\r
+ public interface TabListener {\r
+ /**\r
+ * Called when a tab enters the selected state.\r
+ *\r
+ * @param tab The tab that was selected\r
+ * @param ft A {@link FragmentTransaction} for queuing fragment operations to execute\r
+ * during a tab switch. The previous tab's unselect and this tab's select will be\r
+ * executed in a single transaction. This FragmentTransaction does not support\r
+ * being added to the back stack.\r
+ */\r
+ public void onTabSelected(Tab tab, FragmentTransaction ft);\r
+\r
+ /**\r
+ * Called when a tab exits the selected state.\r
+ *\r
+ * @param tab The tab that was unselected\r
+ * @param ft A {@link FragmentTransaction} for queuing fragment operations to execute\r
+ * during a tab switch. This tab's unselect and the newly selected tab's select\r
+ * will be executed in a single transaction. This FragmentTransaction does not\r
+ * support being added to the back stack.\r
+ */\r
+ public void onTabUnselected(Tab tab, FragmentTransaction ft);\r
+\r
+ /**\r
+ * Called when a tab that is already selected is chosen again by the user.\r
+ * Some applications may use this action to return to the top level of a category.\r
+ *\r
+ * @param tab The tab that was reselected.\r
+ * @param ft A {@link FragmentTransaction} for queuing fragment operations to execute\r
+ * once this method returns. This FragmentTransaction does not support\r
+ * being added to the back stack.\r
+ */\r
+ public void onTabReselected(Tab tab, FragmentTransaction ft);\r
+ }\r
+\r
+ /**\r
+ * Per-child layout information associated with action bar custom views.\r
+ *\r
+ * @attr ref android.R.styleable#ActionBar_LayoutParams_layout_gravity\r
+ */\r
+ public static class LayoutParams extends MarginLayoutParams {\r
+ /**\r
+ * Gravity for the view associated with these LayoutParams.\r
+ *\r
+ * @see android.view.Gravity\r
+ */\r
+ @ViewDebug.ExportedProperty(mapping = {\r
+ @ViewDebug.IntToString(from = -1, to = "NONE"),\r
+ @ViewDebug.IntToString(from = Gravity.NO_GRAVITY, to = "NONE"),\r
+ @ViewDebug.IntToString(from = Gravity.TOP, to = "TOP"),\r
+ @ViewDebug.IntToString(from = Gravity.BOTTOM, to = "BOTTOM"),\r
+ @ViewDebug.IntToString(from = Gravity.LEFT, to = "LEFT"),\r
+ @ViewDebug.IntToString(from = Gravity.RIGHT, to = "RIGHT"),\r
+ @ViewDebug.IntToString(from = Gravity.CENTER_VERTICAL, to = "CENTER_VERTICAL"),\r
+ @ViewDebug.IntToString(from = Gravity.FILL_VERTICAL, to = "FILL_VERTICAL"),\r
+ @ViewDebug.IntToString(from = Gravity.CENTER_HORIZONTAL, to = "CENTER_HORIZONTAL"),\r
+ @ViewDebug.IntToString(from = Gravity.FILL_HORIZONTAL, to = "FILL_HORIZONTAL"),\r
+ @ViewDebug.IntToString(from = Gravity.CENTER, to = "CENTER"),\r
+ @ViewDebug.IntToString(from = Gravity.FILL, to = "FILL")\r
+ })\r
+ public int gravity = -1;\r
+\r
+ public LayoutParams(Context c, AttributeSet attrs) {\r
+ super(c, attrs);\r
+ }\r
+\r
+ public LayoutParams(int width, int height) {\r
+ super(width, height);\r
+ this.gravity = Gravity.CENTER_VERTICAL | Gravity.LEFT;\r
+ }\r
+\r
+ public LayoutParams(int width, int height, int gravity) {\r
+ super(width, height);\r
+ this.gravity = gravity;\r
+ }\r
+\r
+ public LayoutParams(int gravity) {\r
+ this(WRAP_CONTENT, FILL_PARENT, gravity);\r
+ }\r
+\r
+ public LayoutParams(LayoutParams source) {\r
+ super(source);\r
+\r
+ this.gravity = source.gravity;\r
+ }\r
+\r
+ public LayoutParams(ViewGroup.LayoutParams source) {\r
+ super(source);\r
+ }\r
+ }\r
+}\r