create changelog entry
[debian/openrocket] / android-libraries / ActionBarSherlock / src / com / actionbarsherlock / app / ActionBar.java
1 /*\r
2  * Copyright (C) 2010 The Android Open Source Project\r
3  *\r
4  * Licensed under the Apache License, Version 2.0 (the "License");\r
5  * you may not use this file except in compliance with the License.\r
6  * You may obtain a copy of the License at\r
7  *\r
8  *      http://www.apache.org/licenses/LICENSE-2.0\r
9  *\r
10  * Unless required by applicable law or agreed to in writing, software\r
11  * distributed under the License is distributed on an "AS IS" BASIS,\r
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
13  * See the License for the specific language governing permissions and\r
14  * limitations under the License.\r
15  */\r
16 \r
17 package com.actionbarsherlock.app;\r
18 \r
19 import android.content.Context;\r
20 import android.graphics.drawable.Drawable;\r
21 import android.support.v4.app.FragmentTransaction;\r
22 import android.util.AttributeSet;\r
23 import android.view.Gravity;\r
24 import android.view.View;\r
25 import android.view.ViewDebug;\r
26 import android.view.ViewGroup;\r
27 import android.view.ViewGroup.MarginLayoutParams;\r
28 import android.widget.SpinnerAdapter;\r
29 \r
30 /**\r
31  * A window feature at the top of the activity that may display the activity title, navigation\r
32  * modes, and other interactive items.\r
33  * <p>Beginning with Android 3.0 (API level 11), the action bar appears at the top of an\r
34  * activity's window when the activity uses the system's {@link\r
35  * android.R.style#Theme_Holo Holo} theme (or one of its descendant themes), which is the default.\r
36  * You may otherwise add the action bar by calling {@link\r
37  * android.view.Window#requestFeature requestFeature(FEATURE_ACTION_BAR)} or by declaring it in a\r
38  * custom theme with the {@link android.R.styleable#Theme_windowActionBar windowActionBar} property.\r
39  * <p>By default, the action bar shows the application icon on\r
40  * the left, followed by the activity title. If your activity has an options menu, you can make\r
41  * select items accessible directly from the action bar as "action items". You can also\r
42  * modify various characteristics of the action bar or remove it completely.</p>\r
43  * <p>From your activity, you can retrieve an instance of {@link ActionBar} by calling {@link\r
44  * android.app.Activity#getActionBar getActionBar()}.</p>\r
45  * <p>In some cases, the action bar may be overlayed by another bar that enables contextual actions,\r
46  * using an {@link android.view.ActionMode}. For example, when the user selects one or more items in\r
47  * your activity, you can enable an action mode that offers actions specific to the selected\r
48  * items, with a UI that temporarily replaces the action bar. Although the UI may occupy the\r
49  * same space, the {@link android.view.ActionMode} APIs are distinct and independent from those for\r
50  * {@link ActionBar}.\r
51  * <div class="special reference">\r
52  * <h3>Developer Guides</h3>\r
53  * <p>For information about how to use the action bar, including how to add action items, navigation\r
54  * modes and more, read the <a href="{@docRoot}guide/topics/ui/actionbar.html">Action\r
55  * Bar</a> developer guide.</p>\r
56  * </div>\r
57  */\r
58 public abstract class ActionBar {\r
59     /**\r
60      * Standard navigation mode. Consists of either a logo or icon\r
61      * and title text with an optional subtitle. Clicking any of these elements\r
62      * will dispatch onOptionsItemSelected to the host Activity with\r
63      * a MenuItem with item ID android.R.id.home.\r
64      */\r
65     public static final int NAVIGATION_MODE_STANDARD = android.app.ActionBar.NAVIGATION_MODE_STANDARD;\r
66 \r
67     /**\r
68      * List navigation mode. Instead of static title text this mode\r
69      * presents a list menu for navigation within the activity.\r
70      * e.g. this might be presented to the user as a dropdown list.\r
71      */\r
72     public static final int NAVIGATION_MODE_LIST = android.app.ActionBar.NAVIGATION_MODE_LIST;\r
73 \r
74     /**\r
75      * Tab navigation mode. Instead of static title text this mode\r
76      * presents a series of tabs for navigation within the activity.\r
77      */\r
78     public static final int NAVIGATION_MODE_TABS = android.app.ActionBar.NAVIGATION_MODE_TABS;\r
79 \r
80     /**\r
81      * Use logo instead of icon if available. This flag will cause appropriate\r
82      * navigation modes to use a wider logo in place of the standard icon.\r
83      *\r
84      * @see #setDisplayOptions(int)\r
85      * @see #setDisplayOptions(int, int)\r
86      */\r
87     public static final int DISPLAY_USE_LOGO = android.app.ActionBar.DISPLAY_USE_LOGO;\r
88 \r
89     /**\r
90      * Show 'home' elements in this action bar, leaving more space for other\r
91      * navigation elements. This includes logo and icon.\r
92      *\r
93      * @see #setDisplayOptions(int)\r
94      * @see #setDisplayOptions(int, int)\r
95      */\r
96     public static final int DISPLAY_SHOW_HOME = android.app.ActionBar.DISPLAY_SHOW_HOME;\r
97 \r
98     /**\r
99      * Display the 'home' element such that it appears as an 'up' affordance.\r
100      * e.g. show an arrow to the left indicating the action that will be taken.\r
101      *\r
102      * Set this flag if selecting the 'home' button in the action bar to return\r
103      * up by a single level in your UI rather than back to the top level or front page.\r
104      *\r
105      * <p>Setting this option will implicitly enable interaction with the home/up\r
106      * button. See {@link #setHomeButtonEnabled(boolean)}.\r
107      *\r
108      * @see #setDisplayOptions(int)\r
109      * @see #setDisplayOptions(int, int)\r
110      */\r
111     public static final int DISPLAY_HOME_AS_UP = android.app.ActionBar.DISPLAY_HOME_AS_UP;\r
112 \r
113     /**\r
114      * Show the activity title and subtitle, if present.\r
115      *\r
116      * @see #setTitle(CharSequence)\r
117      * @see #setTitle(int)\r
118      * @see #setSubtitle(CharSequence)\r
119      * @see #setSubtitle(int)\r
120      * @see #setDisplayOptions(int)\r
121      * @see #setDisplayOptions(int, int)\r
122      */\r
123     public static final int DISPLAY_SHOW_TITLE = android.app.ActionBar.DISPLAY_SHOW_TITLE;\r
124 \r
125     /**\r
126      * Show the custom view if one has been set.\r
127      * @see #setCustomView(View)\r
128      * @see #setDisplayOptions(int)\r
129      * @see #setDisplayOptions(int, int)\r
130      */\r
131     public static final int DISPLAY_SHOW_CUSTOM = android.app.ActionBar.DISPLAY_SHOW_CUSTOM;\r
132 \r
133     /**\r
134      * Set the action bar into custom navigation mode, supplying a view\r
135      * for custom navigation.\r
136      *\r
137      * Custom navigation views appear between the application icon and\r
138      * any action buttons and may use any space available there. Common\r
139      * use cases for custom navigation views might include an auto-suggesting\r
140      * address bar for a browser or other navigation mechanisms that do not\r
141      * translate well to provided navigation modes.\r
142      *\r
143      * @param view Custom navigation view to place in the ActionBar.\r
144      */\r
145     public abstract void setCustomView(View view);\r
146 \r
147     /**\r
148      * Set the action bar into custom navigation mode, supplying a view\r
149      * for custom navigation.\r
150      *\r
151      * <p>Custom navigation views appear between the application icon and\r
152      * any action buttons and may use any space available there. Common\r
153      * use cases for custom navigation views might include an auto-suggesting\r
154      * address bar for a browser or other navigation mechanisms that do not\r
155      * translate well to provided navigation modes.</p>\r
156      *\r
157      * <p>The display option {@link #DISPLAY_SHOW_CUSTOM} must be set for\r
158      * the custom view to be displayed.</p>\r
159      *\r
160      * @param view Custom navigation view to place in the ActionBar.\r
161      * @param layoutParams How this custom view should layout in the bar.\r
162      *\r
163      * @see #setDisplayOptions(int, int)\r
164      */\r
165     public abstract void setCustomView(View view, LayoutParams layoutParams);\r
166 \r
167     /**\r
168      * Set the action bar into custom navigation mode, supplying a view\r
169      * for custom navigation.\r
170      *\r
171      * <p>Custom navigation views appear between the application icon and\r
172      * any action buttons and may use any space available there. Common\r
173      * use cases for custom navigation views might include an auto-suggesting\r
174      * address bar for a browser or other navigation mechanisms that do not\r
175      * translate well to provided navigation modes.</p>\r
176      *\r
177      * <p>The display option {@link #DISPLAY_SHOW_CUSTOM} must be set for\r
178      * the custom view to be displayed.</p>\r
179      *\r
180      * @param resId Resource ID of a layout to inflate into the ActionBar.\r
181      *\r
182      * @see #setDisplayOptions(int, int)\r
183      */\r
184     public abstract void setCustomView(int resId);\r
185 \r
186     /**\r
187      * Set the icon to display in the 'home' section of the action bar.\r
188      * The action bar will use an icon specified by its style or the\r
189      * activity icon by default.\r
190      *\r
191      * Whether the home section shows an icon or logo is controlled\r
192      * by the display option {@link #DISPLAY_USE_LOGO}.\r
193      *\r
194      * @param resId Resource ID of a drawable to show as an icon.\r
195      *\r
196      * @see #setDisplayUseLogoEnabled(boolean)\r
197      * @see #setDisplayShowHomeEnabled(boolean)\r
198      */\r
199     public abstract void setIcon(int resId);\r
200 \r
201     /**\r
202      * Set the icon to display in the 'home' section of the action bar.\r
203      * The action bar will use an icon specified by its style or the\r
204      * activity icon by default.\r
205      *\r
206      * Whether the home section shows an icon or logo is controlled\r
207      * by the display option {@link #DISPLAY_USE_LOGO}.\r
208      *\r
209      * @param icon Drawable to show as an icon.\r
210      *\r
211      * @see #setDisplayUseLogoEnabled(boolean)\r
212      * @see #setDisplayShowHomeEnabled(boolean)\r
213      */\r
214     public abstract void setIcon(Drawable icon);\r
215 \r
216     /**\r
217      * Set the logo to display in the 'home' section of the action bar.\r
218      * The action bar will use a logo specified by its style or the\r
219      * activity logo by default.\r
220      *\r
221      * Whether the home section shows an icon or logo is controlled\r
222      * by the display option {@link #DISPLAY_USE_LOGO}.\r
223      *\r
224      * @param resId Resource ID of a drawable to show as a logo.\r
225      *\r
226      * @see #setDisplayUseLogoEnabled(boolean)\r
227      * @see #setDisplayShowHomeEnabled(boolean)\r
228      */\r
229     public abstract void setLogo(int resId);\r
230 \r
231     /**\r
232      * Set the logo to display in the 'home' section of the action bar.\r
233      * The action bar will use a logo specified by its style or the\r
234      * activity logo by default.\r
235      *\r
236      * Whether the home section shows an icon or logo is controlled\r
237      * by the display option {@link #DISPLAY_USE_LOGO}.\r
238      *\r
239      * @param logo Drawable to show as a logo.\r
240      *\r
241      * @see #setDisplayUseLogoEnabled(boolean)\r
242      * @see #setDisplayShowHomeEnabled(boolean)\r
243      */\r
244     public abstract void setLogo(Drawable logo);\r
245 \r
246     /**\r
247      * Set the adapter and navigation callback for list navigation mode.\r
248      *\r
249      * The supplied adapter will provide views for the expanded list as well as\r
250      * the currently selected item. (These may be displayed differently.)\r
251      *\r
252      * The supplied OnNavigationListener will alert the application when the user\r
253      * changes the current list selection.\r
254      *\r
255      * @param adapter An adapter that will provide views both to display\r
256      *                the current navigation selection and populate views\r
257      *                within the dropdown navigation menu.\r
258      * @param callback An OnNavigationListener that will receive events when the user\r
259      *                 selects a navigation item.\r
260      */\r
261     public abstract void setListNavigationCallbacks(SpinnerAdapter adapter,\r
262             OnNavigationListener callback);\r
263 \r
264     /**\r
265      * Set the selected navigation item in list or tabbed navigation modes.\r
266      *\r
267      * @param position Position of the item to select.\r
268      */\r
269     public abstract void setSelectedNavigationItem(int position);\r
270 \r
271     /**\r
272      * Get the position of the selected navigation item in list or tabbed navigation modes.\r
273      *\r
274      * @return Position of the selected item.\r
275      */\r
276     public abstract int getSelectedNavigationIndex();\r
277 \r
278     /**\r
279      * Get the number of navigation items present in the current navigation mode.\r
280      *\r
281      * @return Number of navigation items.\r
282      */\r
283     public abstract int getNavigationItemCount();\r
284 \r
285     /**\r
286      * Set the action bar's title. This will only be displayed if\r
287      * {@link #DISPLAY_SHOW_TITLE} is set.\r
288      *\r
289      * @param title Title to set\r
290      *\r
291      * @see #setTitle(int)\r
292      * @see #setDisplayOptions(int, int)\r
293      */\r
294     public abstract void setTitle(CharSequence title);\r
295 \r
296     /**\r
297      * Set the action bar's title. This will only be displayed if\r
298      * {@link #DISPLAY_SHOW_TITLE} is set.\r
299      *\r
300      * @param resId Resource ID of title string to set\r
301      *\r
302      * @see #setTitle(CharSequence)\r
303      * @see #setDisplayOptions(int, int)\r
304      */\r
305     public abstract void setTitle(int resId);\r
306 \r
307     /**\r
308      * Set the action bar's subtitle. This will only be displayed if\r
309      * {@link #DISPLAY_SHOW_TITLE} is set. Set to null to disable the\r
310      * subtitle entirely.\r
311      *\r
312      * @param subtitle Subtitle to set\r
313      *\r
314      * @see #setSubtitle(int)\r
315      * @see #setDisplayOptions(int, int)\r
316      */\r
317     public abstract void setSubtitle(CharSequence subtitle);\r
318 \r
319     /**\r
320      * Set the action bar's subtitle. This will only be displayed if\r
321      * {@link #DISPLAY_SHOW_TITLE} is set.\r
322      *\r
323      * @param resId Resource ID of subtitle string to set\r
324      *\r
325      * @see #setSubtitle(CharSequence)\r
326      * @see #setDisplayOptions(int, int)\r
327      */\r
328     public abstract void setSubtitle(int resId);\r
329 \r
330     /**\r
331      * Set display options. This changes all display option bits at once. To change\r
332      * a limited subset of display options, see {@link #setDisplayOptions(int, int)}.\r
333      *\r
334      * @param options A combination of the bits defined by the DISPLAY_ constants\r
335      *                defined in ActionBar.\r
336      */\r
337     public abstract void setDisplayOptions(int options);\r
338 \r
339     /**\r
340      * Set selected display options. Only the options specified by mask will be changed.\r
341      * To change all display option bits at once, see {@link #setDisplayOptions(int)}.\r
342      *\r
343      * <p>Example: setDisplayOptions(0, DISPLAY_SHOW_HOME) will disable the\r
344      * {@link #DISPLAY_SHOW_HOME} option.\r
345      * setDisplayOptions(DISPLAY_SHOW_HOME, DISPLAY_SHOW_HOME | DISPLAY_USE_LOGO)\r
346      * will enable {@link #DISPLAY_SHOW_HOME} and disable {@link #DISPLAY_USE_LOGO}.\r
347      *\r
348      * @param options A combination of the bits defined by the DISPLAY_ constants\r
349      *                defined in ActionBar.\r
350      * @param mask A bit mask declaring which display options should be changed.\r
351      */\r
352     public abstract void setDisplayOptions(int options, int mask);\r
353 \r
354     /**\r
355      * Set whether to display the activity logo rather than the activity icon.\r
356      * A logo is often a wider, more detailed image.\r
357      *\r
358      * <p>To set several display options at once, see the setDisplayOptions methods.\r
359      *\r
360      * @param useLogo true to use the activity logo, false to use the activity icon.\r
361      *\r
362      * @see #setDisplayOptions(int)\r
363      * @see #setDisplayOptions(int, int)\r
364      */\r
365     public abstract void setDisplayUseLogoEnabled(boolean useLogo);\r
366 \r
367     /**\r
368      * Set whether to include the application home affordance in the action bar.\r
369      * Home is presented as either an activity icon or logo.\r
370      *\r
371      * <p>To set several display options at once, see the setDisplayOptions methods.\r
372      *\r
373      * @param showHome true to show home, false otherwise.\r
374      *\r
375      * @see #setDisplayOptions(int)\r
376      * @see #setDisplayOptions(int, int)\r
377      */\r
378     public abstract void setDisplayShowHomeEnabled(boolean showHome);\r
379 \r
380     /**\r
381      * Set whether home should be displayed as an "up" affordance.\r
382      * Set this to true if selecting "home" returns up by a single level in your UI\r
383      * rather than back to the top level or front page.\r
384      *\r
385      * <p>To set several display options at once, see the setDisplayOptions methods.\r
386      *\r
387      * @param showHomeAsUp true to show the user that selecting home will return one\r
388      *                     level up rather than to the top level of the app.\r
389      *\r
390      * @see #setDisplayOptions(int)\r
391      * @see #setDisplayOptions(int, int)\r
392      */\r
393     public abstract void setDisplayHomeAsUpEnabled(boolean showHomeAsUp);\r
394 \r
395     /**\r
396      * Set whether an activity title/subtitle should be displayed.\r
397      *\r
398      * <p>To set several display options at once, see the setDisplayOptions methods.\r
399      *\r
400      * @param showTitle true to display a title/subtitle if present.\r
401      *\r
402      * @see #setDisplayOptions(int)\r
403      * @see #setDisplayOptions(int, int)\r
404      */\r
405     public abstract void setDisplayShowTitleEnabled(boolean showTitle);\r
406 \r
407     /**\r
408      * Set whether a custom view should be displayed, if set.\r
409      *\r
410      * <p>To set several display options at once, see the setDisplayOptions methods.\r
411      *\r
412      * @param showCustom true if the currently set custom view should be displayed, false otherwise.\r
413      *\r
414      * @see #setDisplayOptions(int)\r
415      * @see #setDisplayOptions(int, int)\r
416      */\r
417     public abstract void setDisplayShowCustomEnabled(boolean showCustom);\r
418 \r
419     /**\r
420      * Set the ActionBar's background. This will be used for the primary\r
421      * action bar.\r
422      *\r
423      * @param d Background drawable\r
424      * @see #setStackedBackgroundDrawable(Drawable)\r
425      * @see #setSplitBackgroundDrawable(Drawable)\r
426      */\r
427     public abstract void setBackgroundDrawable(Drawable d);\r
428 \r
429     /**\r
430      * Set the ActionBar's stacked background. This will appear\r
431      * in the second row/stacked bar on some devices and configurations.\r
432      *\r
433      * @param d Background drawable for the stacked row\r
434      */\r
435     public void setStackedBackgroundDrawable(Drawable d) { }\r
436 \r
437     /**\r
438      * Set the ActionBar's split background. This will appear in\r
439      * the split action bar containing menu-provided action buttons\r
440      * on some devices and configurations.\r
441      * <p>You can enable split action bar with {@link android.R.attr#uiOptions}\r
442      *\r
443      * @param d Background drawable for the split bar\r
444      */\r
445     public void setSplitBackgroundDrawable(Drawable d) { }\r
446 \r
447     /**\r
448      * @return The current custom view.\r
449      */\r
450     public abstract View getCustomView();\r
451 \r
452     /**\r
453      * Returns the current ActionBar title in standard mode.\r
454      * Returns null if {@link #getNavigationMode()} would not return\r
455      * {@link #NAVIGATION_MODE_STANDARD}.\r
456      *\r
457      * @return The current ActionBar title or null.\r
458      */\r
459     public abstract CharSequence getTitle();\r
460 \r
461     /**\r
462      * Returns the current ActionBar subtitle in standard mode.\r
463      * Returns null if {@link #getNavigationMode()} would not return\r
464      * {@link #NAVIGATION_MODE_STANDARD}.\r
465      *\r
466      * @return The current ActionBar subtitle or null.\r
467      */\r
468     public abstract CharSequence getSubtitle();\r
469 \r
470     /**\r
471      * Returns the current navigation mode. The result will be one of:\r
472      * <ul>\r
473      * <li>{@link #NAVIGATION_MODE_STANDARD}</li>\r
474      * <li>{@link #NAVIGATION_MODE_LIST}</li>\r
475      * <li>{@link #NAVIGATION_MODE_TABS}</li>\r
476      * </ul>\r
477      *\r
478      * @return The current navigation mode.\r
479      */\r
480     public abstract int getNavigationMode();\r
481 \r
482     /**\r
483      * Set the current navigation mode.\r
484      *\r
485      * @param mode The new mode to set.\r
486      * @see #NAVIGATION_MODE_STANDARD\r
487      * @see #NAVIGATION_MODE_LIST\r
488      * @see #NAVIGATION_MODE_TABS\r
489      */\r
490     public abstract void setNavigationMode(int mode);\r
491 \r
492     /**\r
493      * @return The current set of display options.\r
494      */\r
495     public abstract int getDisplayOptions();\r
496 \r
497     /**\r
498      * Create and return a new {@link Tab}.\r
499      * This tab will not be included in the action bar until it is added.\r
500      *\r
501      * <p>Very often tabs will be used to switch between {@link Fragment}\r
502      * objects.  Here is a typical implementation of such tabs:</p>\r
503      *\r
504      * {@sample development/samples/ApiDemos/src/com/example/android/apis/app/FragmentTabs.java\r
505      *      complete}\r
506      *\r
507      * @return A new Tab\r
508      *\r
509      * @see #addTab(Tab)\r
510      */\r
511     public abstract Tab newTab();\r
512 \r
513     /**\r
514      * Add a tab for use in tabbed navigation mode. The tab will be added at the end of the list.\r
515      * If this is the first tab to be added it will become the selected tab.\r
516      *\r
517      * @param tab Tab to add\r
518      */\r
519     public abstract void addTab(Tab tab);\r
520 \r
521     /**\r
522      * Add a tab for use in tabbed navigation mode. The tab will be added at the end of the list.\r
523      *\r
524      * @param tab Tab to add\r
525      * @param setSelected True if the added tab should become the selected tab.\r
526      */\r
527     public abstract void addTab(Tab tab, boolean setSelected);\r
528 \r
529     /**\r
530      * Add a tab for use in tabbed navigation mode. The tab will be inserted at\r
531      * <code>position</code>. If this is the first tab to be added it will become\r
532      * the selected tab.\r
533      *\r
534      * @param tab The tab to add\r
535      * @param position The new position of the tab\r
536      */\r
537     public abstract void addTab(Tab tab, int position);\r
538 \r
539     /**\r
540      * Add a tab for use in tabbed navigation mode. The tab will be insterted at\r
541      * <code>position</code>.\r
542      *\r
543      * @param tab The tab to add\r
544      * @param position The new position of the tab\r
545      * @param setSelected True if the added tab should become the selected tab.\r
546      */\r
547     public abstract void addTab(Tab tab, int position, boolean setSelected);\r
548 \r
549     /**\r
550      * Remove a tab from the action bar. If the removed tab was selected it will be deselected\r
551      * and another tab will be selected if present.\r
552      *\r
553      * @param tab The tab to remove\r
554      */\r
555     public abstract void removeTab(Tab tab);\r
556 \r
557     /**\r
558      * Remove a tab from the action bar. If the removed tab was selected it will be deselected\r
559      * and another tab will be selected if present.\r
560      *\r
561      * @param position Position of the tab to remove\r
562      */\r
563     public abstract void removeTabAt(int position);\r
564 \r
565     /**\r
566      * Remove all tabs from the action bar and deselect the current tab.\r
567      */\r
568     public abstract void removeAllTabs();\r
569 \r
570     /**\r
571      * Select the specified tab. If it is not a child of this action bar it will be added.\r
572      *\r
573      * <p>Note: If you want to select by index, use {@link #setSelectedNavigationItem(int)}.</p>\r
574      *\r
575      * @param tab Tab to select\r
576      */\r
577     public abstract void selectTab(Tab tab);\r
578 \r
579     /**\r
580      * Returns the currently selected tab if in tabbed navigation mode and there is at least\r
581      * one tab present.\r
582      *\r
583      * @return The currently selected tab or null\r
584      */\r
585     public abstract Tab getSelectedTab();\r
586 \r
587     /**\r
588      * Returns the tab at the specified index.\r
589      *\r
590      * @param index Index value in the range 0-get\r
591      * @return\r
592      */\r
593     public abstract Tab getTabAt(int index);\r
594 \r
595     /**\r
596      * Returns the number of tabs currently registered with the action bar.\r
597      * @return Tab count\r
598      */\r
599     public abstract int getTabCount();\r
600 \r
601     /**\r
602      * Retrieve the current height of the ActionBar.\r
603      *\r
604      * @return The ActionBar's height\r
605      */\r
606     public abstract int getHeight();\r
607 \r
608     /**\r
609      * Show the ActionBar if it is not currently showing.\r
610      * If the window hosting the ActionBar does not have the feature\r
611      * {@link Window#FEATURE_ACTION_BAR_OVERLAY} it will resize application\r
612      * content to fit the new space available.\r
613      */\r
614     public abstract void show();\r
615 \r
616     /**\r
617      * Hide the ActionBar if it is currently showing.\r
618      * If the window hosting the ActionBar does not have the feature\r
619      * {@link Window#FEATURE_ACTION_BAR_OVERLAY} it will resize application\r
620      * content to fit the new space available.\r
621      */\r
622     public abstract void hide();\r
623 \r
624     /**\r
625      * @return <code>true</code> if the ActionBar is showing, <code>false</code> otherwise.\r
626      */\r
627     public abstract boolean isShowing();\r
628 \r
629     /**\r
630      * Add a listener that will respond to menu visibility change events.\r
631      *\r
632      * @param listener The new listener to add\r
633      */\r
634     public abstract void addOnMenuVisibilityListener(OnMenuVisibilityListener listener);\r
635 \r
636     /**\r
637      * Remove a menu visibility listener. This listener will no longer receive menu\r
638      * visibility change events.\r
639      *\r
640      * @param listener A listener to remove that was previously added\r
641      */\r
642     public abstract void removeOnMenuVisibilityListener(OnMenuVisibilityListener listener);\r
643 \r
644     /**\r
645      * Enable or disable the "home" button in the corner of the action bar. (Note that this\r
646      * is the application home/up affordance on the action bar, not the systemwide home\r
647      * button.)\r
648      *\r
649      * <p>This defaults to true for packages targeting &lt; API 14. For packages targeting\r
650      * API 14 or greater, the application should call this method to enable interaction\r
651      * with the home/up affordance.\r
652      *\r
653      * <p>Setting the {@link #DISPLAY_HOME_AS_UP} display option will automatically enable\r
654      * the home button.\r
655      *\r
656      * @param enabled true to enable the home button, false to disable the home button.\r
657      */\r
658     public void setHomeButtonEnabled(boolean enabled) { }\r
659 \r
660     /**\r
661      * Returns a {@link Context} with an appropriate theme for creating views that\r
662      * will appear in the action bar. If you are inflating or instantiating custom views\r
663      * that will appear in an action bar, you should use the Context returned by this method.\r
664      * (This includes adapters used for list navigation mode.)\r
665      * This will ensure that views contrast properly against the action bar.\r
666      *\r
667      * @return A themed Context for creating views\r
668      */\r
669     public Context getThemedContext() { return null; }\r
670 \r
671     /**\r
672      * Listener interface for ActionBar navigation events.\r
673      */\r
674     public interface OnNavigationListener {\r
675         /**\r
676          * This method is called whenever a navigation item in your action bar\r
677          * is selected.\r
678          *\r
679          * @param itemPosition Position of the item clicked.\r
680          * @param itemId ID of the item clicked.\r
681          * @return True if the event was handled, false otherwise.\r
682          */\r
683         public boolean onNavigationItemSelected(int itemPosition, long itemId);\r
684     }\r
685 \r
686     /**\r
687      * Listener for receiving events when action bar menus are shown or hidden.\r
688      */\r
689     public interface OnMenuVisibilityListener {\r
690         /**\r
691          * Called when an action bar menu is shown or hidden. Applications may want to use\r
692          * this to tune auto-hiding behavior for the action bar or pause/resume video playback,\r
693          * gameplay, or other activity within the main content area.\r
694          *\r
695          * @param isVisible True if an action bar menu is now visible, false if no action bar\r
696          *                  menus are visible.\r
697          */\r
698         public void onMenuVisibilityChanged(boolean isVisible);\r
699     }\r
700 \r
701     /**\r
702      * A tab in the action bar.\r
703      *\r
704      * <p>Tabs manage the hiding and showing of {@link Fragment}s.\r
705      */\r
706     public static abstract class Tab {\r
707         /**\r
708          * An invalid position for a tab.\r
709          *\r
710          * @see #getPosition()\r
711          */\r
712         public static final int INVALID_POSITION = -1;\r
713 \r
714         /**\r
715          * Return the current position of this tab in the action bar.\r
716          *\r
717          * @return Current position, or {@link #INVALID_POSITION} if this tab is not currently in\r
718          *         the action bar.\r
719          */\r
720         public abstract int getPosition();\r
721 \r
722         /**\r
723          * Return the icon associated with this tab.\r
724          *\r
725          * @return The tab's icon\r
726          */\r
727         public abstract Drawable getIcon();\r
728 \r
729         /**\r
730          * Return the text of this tab.\r
731          *\r
732          * @return The tab's text\r
733          */\r
734         public abstract CharSequence getText();\r
735 \r
736         /**\r
737          * Set the icon displayed on this tab.\r
738          *\r
739          * @param icon The drawable to use as an icon\r
740          * @return The current instance for call chaining\r
741          */\r
742         public abstract Tab setIcon(Drawable icon);\r
743 \r
744         /**\r
745          * Set the icon displayed on this tab.\r
746          *\r
747          * @param resId Resource ID referring to the drawable to use as an icon\r
748          * @return The current instance for call chaining\r
749          */\r
750         public abstract Tab setIcon(int resId);\r
751 \r
752         /**\r
753          * Set the text displayed on this tab. Text may be truncated if there is not\r
754          * room to display the entire string.\r
755          *\r
756          * @param text The text to display\r
757          * @return The current instance for call chaining\r
758          */\r
759         public abstract Tab setText(CharSequence text);\r
760 \r
761         /**\r
762          * Set the text displayed on this tab. Text may be truncated if there is not\r
763          * room to display the entire string.\r
764          *\r
765          * @param resId A resource ID referring to the text that should be displayed\r
766          * @return The current instance for call chaining\r
767          */\r
768         public abstract Tab setText(int resId);\r
769 \r
770         /**\r
771          * Set a custom view to be used for this tab. This overrides values set by\r
772          * {@link #setText(CharSequence)} and {@link #setIcon(Drawable)}.\r
773          *\r
774          * @param view Custom view to be used as a tab.\r
775          * @return The current instance for call chaining\r
776          */\r
777         public abstract Tab setCustomView(View view);\r
778 \r
779         /**\r
780          * Set a custom view to be used for this tab. This overrides values set by\r
781          * {@link #setText(CharSequence)} and {@link #setIcon(Drawable)}.\r
782          *\r
783          * @param layoutResId A layout resource to inflate and use as a custom tab view\r
784          * @return The current instance for call chaining\r
785          */\r
786         public abstract Tab setCustomView(int layoutResId);\r
787 \r
788         /**\r
789          * Retrieve a previously set custom view for this tab.\r
790          *\r
791          * @return The custom view set by {@link #setCustomView(View)}.\r
792          */\r
793         public abstract View getCustomView();\r
794 \r
795         /**\r
796          * Give this Tab an arbitrary object to hold for later use.\r
797          *\r
798          * @param obj Object to store\r
799          * @return The current instance for call chaining\r
800          */\r
801         public abstract Tab setTag(Object obj);\r
802 \r
803         /**\r
804          * @return This Tab's tag object.\r
805          */\r
806         public abstract Object getTag();\r
807 \r
808         /**\r
809          * Set the {@link TabListener} that will handle switching to and from this tab.\r
810          * All tabs must have a TabListener set before being added to the ActionBar.\r
811          *\r
812          * @param listener Listener to handle tab selection events\r
813          * @return The current instance for call chaining\r
814          */\r
815         public abstract Tab setTabListener(TabListener listener);\r
816 \r
817         /**\r
818          * Select this tab. Only valid if the tab has been added to the action bar.\r
819          */\r
820         public abstract void select();\r
821 \r
822         /**\r
823          * Set a description of this tab's content for use in accessibility support.\r
824          * If no content description is provided the title will be used.\r
825          *\r
826          * @param resId A resource ID referring to the description text\r
827          * @return The current instance for call chaining\r
828          * @see #setContentDescription(CharSequence)\r
829          * @see #getContentDescription()\r
830          */\r
831         public abstract Tab setContentDescription(int resId);\r
832 \r
833         /**\r
834          * Set a description of this tab's content for use in accessibility support.\r
835          * If no content description is provided the title will be used.\r
836          *\r
837          * @param contentDesc Description of this tab's content\r
838          * @return The current instance for call chaining\r
839          * @see #setContentDescription(int)\r
840          * @see #getContentDescription()\r
841          */\r
842         public abstract Tab setContentDescription(CharSequence contentDesc);\r
843 \r
844         /**\r
845          * Gets a brief description of this tab's content for use in accessibility support.\r
846          *\r
847          * @return Description of this tab's content\r
848          * @see #setContentDescription(CharSequence)\r
849          * @see #setContentDescription(int)\r
850          */\r
851         public abstract CharSequence getContentDescription();\r
852     }\r
853 \r
854     /**\r
855      * Callback interface invoked when a tab is focused, unfocused, added, or removed.\r
856      */\r
857     public interface TabListener {\r
858         /**\r
859          * Called when a tab enters the selected state.\r
860          *\r
861          * @param tab The tab that was selected\r
862          * @param ft A {@link FragmentTransaction} for queuing fragment operations to execute\r
863          *        during a tab switch. The previous tab's unselect and this tab's select will be\r
864          *        executed in a single transaction. This FragmentTransaction does not support\r
865          *        being added to the back stack.\r
866          */\r
867         public void onTabSelected(Tab tab, FragmentTransaction ft);\r
868 \r
869         /**\r
870          * Called when a tab exits the selected state.\r
871          *\r
872          * @param tab The tab that was unselected\r
873          * @param ft A {@link FragmentTransaction} for queuing fragment operations to execute\r
874          *        during a tab switch. This tab's unselect and the newly selected tab's select\r
875          *        will be executed in a single transaction. This FragmentTransaction does not\r
876          *        support being added to the back stack.\r
877          */\r
878         public void onTabUnselected(Tab tab, FragmentTransaction ft);\r
879 \r
880         /**\r
881          * Called when a tab that is already selected is chosen again by the user.\r
882          * Some applications may use this action to return to the top level of a category.\r
883          *\r
884          * @param tab The tab that was reselected.\r
885          * @param ft A {@link FragmentTransaction} for queuing fragment operations to execute\r
886          *        once this method returns. This FragmentTransaction does not support\r
887          *        being added to the back stack.\r
888          */\r
889         public void onTabReselected(Tab tab, FragmentTransaction ft);\r
890     }\r
891 \r
892     /**\r
893      * Per-child layout information associated with action bar custom views.\r
894      *\r
895      * @attr ref android.R.styleable#ActionBar_LayoutParams_layout_gravity\r
896      */\r
897     public static class LayoutParams extends MarginLayoutParams {\r
898         /**\r
899          * Gravity for the view associated with these LayoutParams.\r
900          *\r
901          * @see android.view.Gravity\r
902          */\r
903         @ViewDebug.ExportedProperty(mapping = {\r
904             @ViewDebug.IntToString(from =  -1,                       to = "NONE"),\r
905             @ViewDebug.IntToString(from = Gravity.NO_GRAVITY,        to = "NONE"),\r
906             @ViewDebug.IntToString(from = Gravity.TOP,               to = "TOP"),\r
907             @ViewDebug.IntToString(from = Gravity.BOTTOM,            to = "BOTTOM"),\r
908             @ViewDebug.IntToString(from = Gravity.LEFT,              to = "LEFT"),\r
909             @ViewDebug.IntToString(from = Gravity.RIGHT,             to = "RIGHT"),\r
910             @ViewDebug.IntToString(from = Gravity.CENTER_VERTICAL,   to = "CENTER_VERTICAL"),\r
911             @ViewDebug.IntToString(from = Gravity.FILL_VERTICAL,     to = "FILL_VERTICAL"),\r
912             @ViewDebug.IntToString(from = Gravity.CENTER_HORIZONTAL, to = "CENTER_HORIZONTAL"),\r
913             @ViewDebug.IntToString(from = Gravity.FILL_HORIZONTAL,   to = "FILL_HORIZONTAL"),\r
914             @ViewDebug.IntToString(from = Gravity.CENTER,            to = "CENTER"),\r
915             @ViewDebug.IntToString(from = Gravity.FILL,              to = "FILL")\r
916         })\r
917         public int gravity = -1;\r
918 \r
919         public LayoutParams(Context c, AttributeSet attrs) {\r
920             super(c, attrs);\r
921         }\r
922 \r
923         public LayoutParams(int width, int height) {\r
924             super(width, height);\r
925             this.gravity = Gravity.CENTER_VERTICAL | Gravity.LEFT;\r
926         }\r
927 \r
928         public LayoutParams(int width, int height, int gravity) {\r
929             super(width, height);\r
930             this.gravity = gravity;\r
931         }\r
932 \r
933         public LayoutParams(int gravity) {\r
934             this(WRAP_CONTENT, FILL_PARENT, gravity);\r
935         }\r
936 \r
937         public LayoutParams(LayoutParams source) {\r
938             super(source);\r
939 \r
940             this.gravity = source.gravity;\r
941         }\r
942 \r
943         public LayoutParams(ViewGroup.LayoutParams source) {\r
944             super(source);\r
945         }\r
946     }\r
947 }\r