ActionBar.java revision 661c908e4e26c99adc2cab7558a02129eaee059d
133b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell/* 233b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * Copyright (C) 2010 The Android Open Source Project 333b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * 433b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * Licensed under the Apache License, Version 2.0 (the "License"); 533b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * you may not use this file except in compliance with the License. 633b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * You may obtain a copy of the License at 733b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * 833b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * http://www.apache.org/licenses/LICENSE-2.0 933b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * 1033b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * Unless required by applicable law or agreed to in writing, software 1133b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * distributed under the License is distributed on an "AS IS" BASIS, 1233b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1333b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * See the License for the specific language governing permissions and 1433b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * limitations under the License. 1533b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell */ 1633b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell 1733b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powellpackage android.app; 1833b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell 1933b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powellimport android.graphics.drawable.Drawable; 2033b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powellimport android.view.Menu; 2133b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powellimport android.view.MenuItem; 2233b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powellimport android.view.View; 23a408291e22def5755559f42cde913706a6d628c0Adam Powellimport android.widget.SpinnerAdapter; 2433b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell 2533b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell/** 2633b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * This is the public interface to the contextual ActionBar. 2733b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * The ActionBar acts as a replacement for the title bar in Activities. 2833b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * It provides facilities for creating toolbar actions as well as 2933b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * methods of navigating around an application. 3033b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell */ 3133b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powellpublic abstract class ActionBar { 32a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell /** 33a408291e22def5755559f42cde913706a6d628c0Adam Powell * Standard navigation mode. Consists of either a logo or icon 34a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell * and title text with an optional subtitle. Clicking any of these elements 35a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell * will dispatch onActionItemSelected to the registered Callback with 36a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell * a MenuItem with item ID android.R.id.home. 37a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell */ 38a408291e22def5755559f42cde913706a6d628c0Adam Powell public static final int NAVIGATION_MODE_STANDARD = 0; 3933b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell 4033b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell /** 4133b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * Dropdown list navigation mode. Instead of static title text this mode 4233b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * presents a dropdown menu for navigation within the activity. 4333b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell */ 4433b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell public static final int NAVIGATION_MODE_DROPDOWN_LIST = 1; 4533b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell 4633b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell /** 4733b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * Tab navigation mode. Instead of static title text this mode 4833b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * presents a series of tabs for navigation within the activity. 4933b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell */ 5033b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell public static final int NAVIGATION_MODE_TABS = 2; 5133b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell 5233b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell /** 5333b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * Custom navigation mode. This navigation mode is set implicitly whenever 544dc643eb6749afe5211198c920e739475590f92cWink Saville * a custom navigation view is set. See {@link #setCustomNavigationMode(View)}. 5533b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell */ 5633b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell public static final int NAVIGATION_MODE_CUSTOM = 3; 5733b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell 5833b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell /** 5933b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * Use logo instead of icon if available. This flag will cause appropriate 6033b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * navigation modes to use a wider logo in place of the standard icon. 6133b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell */ 6233b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell public static final int DISPLAY_USE_LOGO = 0x1; 6333b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell 6433b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell /** 6533b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * Hide 'home' elements in this action bar, leaving more space for other 6633b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * navigation elements. This includes logo and icon. 6733b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell */ 6833b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell public static final int DISPLAY_HIDE_HOME = 0x2; 6989e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell 7033b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell /** 71a408291e22def5755559f42cde913706a6d628c0Adam Powell * Set the action bar into custom navigation mode, supplying a view 72a408291e22def5755559f42cde913706a6d628c0Adam Powell * for custom navigation. 7333b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * 7433b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * Custom navigation views appear between the application icon and 7533b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * any action buttons and may use any space available there. Common 76a408291e22def5755559f42cde913706a6d628c0Adam Powell * use cases for custom navigation views might include an auto-suggesting 77a408291e22def5755559f42cde913706a6d628c0Adam Powell * address bar for a browser or other navigation mechanisms that do not 78a408291e22def5755559f42cde913706a6d628c0Adam Powell * translate well to provided navigation modes. 7933b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * 8033b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * @param view Custom navigation view to place in the ActionBar. 8133b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell */ 82a408291e22def5755559f42cde913706a6d628c0Adam Powell public abstract void setCustomNavigationMode(View view); 8333b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell 8433b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell /** 85a408291e22def5755559f42cde913706a6d628c0Adam Powell * Set the action bar into dropdown navigation mode and supply an adapter 86a408291e22def5755559f42cde913706a6d628c0Adam Powell * that will provide views for navigation choices. 8733b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * 88a408291e22def5755559f42cde913706a6d628c0Adam Powell * @param adapter An adapter that will provide views both to display 89a408291e22def5755559f42cde913706a6d628c0Adam Powell * the current navigation selection and populate views 90a408291e22def5755559f42cde913706a6d628c0Adam Powell * within the dropdown navigation menu. 9189e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * @param callback A NavigationCallback that will receive events when the user 9289e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * selects a navigation item. 9333b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell */ 9489e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell public abstract void setDropdownNavigationMode(SpinnerAdapter adapter, 9589e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell NavigationCallback callback); 96a408291e22def5755559f42cde913706a6d628c0Adam Powell 9733b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell /** 98a408291e22def5755559f42cde913706a6d628c0Adam Powell * Set the action bar into standard navigation mode, supplying a title and subtitle. 9933b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * 100a408291e22def5755559f42cde913706a6d628c0Adam Powell * Standard navigation mode is default. The title is automatically set to the 101a408291e22def5755559f42cde913706a6d628c0Adam Powell * name of your Activity. Subtitles are displayed underneath the title, usually 102a408291e22def5755559f42cde913706a6d628c0Adam Powell * in a smaller font or otherwise less prominently than the title. Subtitles are 103a408291e22def5755559f42cde913706a6d628c0Adam Powell * good for extended descriptions of activity state. 104a408291e22def5755559f42cde913706a6d628c0Adam Powell * 105a408291e22def5755559f42cde913706a6d628c0Adam Powell * @param title The action bar's title. null is treated as an empty string. 1060e94b5151d817e600a888448a662208b29b5ef46Adam Powell * @param subtitle The action bar's subtitle. null will remove the subtitle entirely. 10733b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell */ 108a408291e22def5755559f42cde913706a6d628c0Adam Powell public abstract void setStandardNavigationMode(CharSequence title, CharSequence subtitle); 109a408291e22def5755559f42cde913706a6d628c0Adam Powell 11033b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell /** 111a408291e22def5755559f42cde913706a6d628c0Adam Powell * Set the action bar into standard navigation mode, supplying a title and subtitle. 112a408291e22def5755559f42cde913706a6d628c0Adam Powell * 113a408291e22def5755559f42cde913706a6d628c0Adam Powell * Standard navigation mode is default. The title is automatically set to the 1140e94b5151d817e600a888448a662208b29b5ef46Adam Powell * name of your Activity on startup if an action bar is present. 11533b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * 116a408291e22def5755559f42cde913706a6d628c0Adam Powell * @param title The action bar's title. null is treated as an empty string. 11733b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell */ 118a408291e22def5755559f42cde913706a6d628c0Adam Powell public abstract void setStandardNavigationMode(CharSequence title); 119a408291e22def5755559f42cde913706a6d628c0Adam Powell 12033b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell /** 1210e94b5151d817e600a888448a662208b29b5ef46Adam Powell * Set the action bar into standard navigation mode, using the currently set title 1220e94b5151d817e600a888448a662208b29b5ef46Adam Powell * and/or subtitle. 1230e94b5151d817e600a888448a662208b29b5ef46Adam Powell * 1240e94b5151d817e600a888448a662208b29b5ef46Adam Powell * Standard navigation mode is default. The title is automatically set to the name of 1250e94b5151d817e600a888448a662208b29b5ef46Adam Powell * your Activity on startup if an action bar is present. 1260e94b5151d817e600a888448a662208b29b5ef46Adam Powell */ 1270e94b5151d817e600a888448a662208b29b5ef46Adam Powell public abstract void setStandardNavigationMode(); 1280e94b5151d817e600a888448a662208b29b5ef46Adam Powell 1290e94b5151d817e600a888448a662208b29b5ef46Adam Powell /** 1300e94b5151d817e600a888448a662208b29b5ef46Adam Powell * Set the action bar's title. This will only be displayed in standard navigation mode. 1310e94b5151d817e600a888448a662208b29b5ef46Adam Powell * 1320e94b5151d817e600a888448a662208b29b5ef46Adam Powell * @param title Title to set 1330e94b5151d817e600a888448a662208b29b5ef46Adam Powell */ 1340e94b5151d817e600a888448a662208b29b5ef46Adam Powell public abstract void setTitle(CharSequence title); 1350e94b5151d817e600a888448a662208b29b5ef46Adam Powell 1360e94b5151d817e600a888448a662208b29b5ef46Adam Powell /** 1370e94b5151d817e600a888448a662208b29b5ef46Adam Powell * Set the action bar's subtitle. This will only be displayed in standard navigation mode. 1380e94b5151d817e600a888448a662208b29b5ef46Adam Powell * Set to null to disable the subtitle entirely. 1390e94b5151d817e600a888448a662208b29b5ef46Adam Powell * 1400e94b5151d817e600a888448a662208b29b5ef46Adam Powell * @param subtitle Subtitle to set 1410e94b5151d817e600a888448a662208b29b5ef46Adam Powell */ 1420e94b5151d817e600a888448a662208b29b5ef46Adam Powell public abstract void setSubtitle(CharSequence subtitle); 1430e94b5151d817e600a888448a662208b29b5ef46Adam Powell 1440e94b5151d817e600a888448a662208b29b5ef46Adam Powell /** 145a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell * Set display options. This changes all display option bits at once. To change 146a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell * a limited subset of display options, see {@link #setDisplayOptions(int, int)}. 14733b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * 14833b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * @param options A combination of the bits defined by the DISPLAY_ constants 14933b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * defined in ActionBar. 15033b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell */ 15133b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell public abstract void setDisplayOptions(int options); 15233b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell 15333b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell /** 154a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell * Set selected display options. Only the options specified by mask will be changed. 155a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell * To change all display option bits at once, see {@link #setDisplayOptions(int)}. 156a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell * 157a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell * <p>Example: setDisplayOptions(0, DISPLAY_HIDE_HOME) will disable the 158a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell * {@link #DISPLAY_HIDE_HOME} option. 159a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell * setDisplayOptions(DISPLAY_HIDE_HOME, DISPLAY_HIDE_HOME | DISPLAY_USE_LOGO) 160a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell * will enable {@link #DISPLAY_HIDE_HOME} and disable {@link #DISPLAY_USE_LOGO}. 161a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell * 162a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell * @param options A combination of the bits defined by the DISPLAY_ constants 163a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell * defined in ActionBar. 164a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell * @param mask A bit mask declaring which display options should be changed. 165a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell */ 166a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell public abstract void setDisplayOptions(int options, int mask); 167a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell 168a1700783b52c3f4e6b52ea425cdce93c74936586Adam Powell /** 16933b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * Set the ActionBar's background. 17033b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * 17133b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * @param d Background drawable 17233b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell */ 17333b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell public abstract void setBackgroundDrawable(Drawable d); 17433b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell 17533b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell /** 17633b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * @return The current custom navigation view. 17733b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell */ 17833b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell public abstract View getCustomNavigationView(); 17933b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell 18033b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell /** 181a408291e22def5755559f42cde913706a6d628c0Adam Powell * Returns the current ActionBar title in standard mode. 182a408291e22def5755559f42cde913706a6d628c0Adam Powell * Returns null if {@link #getNavigationMode()} would not return 183a408291e22def5755559f42cde913706a6d628c0Adam Powell * {@link #NAVIGATION_MODE_STANDARD}. 184a408291e22def5755559f42cde913706a6d628c0Adam Powell * 185a408291e22def5755559f42cde913706a6d628c0Adam Powell * @return The current ActionBar title or null. 18633b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell */ 18733b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell public abstract CharSequence getTitle(); 18833b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell 18933b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell /** 190a408291e22def5755559f42cde913706a6d628c0Adam Powell * Returns the current ActionBar subtitle in standard mode. 191a408291e22def5755559f42cde913706a6d628c0Adam Powell * Returns null if {@link #getNavigationMode()} would not return 192a408291e22def5755559f42cde913706a6d628c0Adam Powell * {@link #NAVIGATION_MODE_STANDARD}. 193a408291e22def5755559f42cde913706a6d628c0Adam Powell * 194a408291e22def5755559f42cde913706a6d628c0Adam Powell * @return The current ActionBar subtitle or null. 19533b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell */ 19633b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell public abstract CharSequence getSubtitle(); 19733b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell 19833b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell /** 199a408291e22def5755559f42cde913706a6d628c0Adam Powell * Returns the current navigation mode. The result will be one of: 200a408291e22def5755559f42cde913706a6d628c0Adam Powell * <ul> 201a408291e22def5755559f42cde913706a6d628c0Adam Powell * <li>{@link #NAVIGATION_MODE_STANDARD}</li> 202a408291e22def5755559f42cde913706a6d628c0Adam Powell * <li>{@link #NAVIGATION_MODE_DROPDOWN_LIST}</li> 203a408291e22def5755559f42cde913706a6d628c0Adam Powell * <li>{@link #NAVIGATION_MODE_TABS}</li> 204a408291e22def5755559f42cde913706a6d628c0Adam Powell * <li>{@link #NAVIGATION_MODE_CUSTOM}</li> 205a408291e22def5755559f42cde913706a6d628c0Adam Powell * </ul> 206a408291e22def5755559f42cde913706a6d628c0Adam Powell * 20733b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * @return The current navigation mode. 208a408291e22def5755559f42cde913706a6d628c0Adam Powell * 209661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @see #setStandardNavigationMode() 210a408291e22def5755559f42cde913706a6d628c0Adam Powell * @see #setStandardNavigationMode(CharSequence) 211a408291e22def5755559f42cde913706a6d628c0Adam Powell * @see #setStandardNavigationMode(CharSequence, CharSequence) 212a408291e22def5755559f42cde913706a6d628c0Adam Powell * @see #setDropdownNavigationMode(SpinnerAdapter) 213661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @see #setTabNavigationMode() 214a408291e22def5755559f42cde913706a6d628c0Adam Powell * @see #setCustomNavigationMode(View) 21533b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell */ 21633b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell public abstract int getNavigationMode(); 21733b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell 21833b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell /** 21933b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell * @return The current set of display options. 22033b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell */ 22133b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell public abstract int getDisplayOptions(); 222661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 223661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 224661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * Start a context mode controlled by <code>callback</code>. 225661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * The {@link ContextModeCallback} will receive lifecycle events for the duration 226661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * of the context mode. 227661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 228661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @param callback Callback handler that will manage this context mode. 229661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 23089e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell public abstract void startContextMode(ContextModeCallback callback); 231661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 232661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 233661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * Finish the current context mode. 234661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 23589e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell public abstract void finishContextMode(); 236661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 237661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 238661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * Set the action bar into tabbed navigation mode. 239661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 240661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @see #addTab(Tab) 241661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @see #insertTab(Tab, int) 242661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @see #removeTab(Tab) 243661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @see #removeTabAt(int) 244661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 245661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell public abstract void setTabNavigationMode(); 246661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 247661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 248661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * Set the action bar into tabbed navigation mode. 249661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 250661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @param containerViewId Id of the container view where tab content fragments should appear. 251661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 252661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @see #addTab(Tab) 253661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @see #insertTab(Tab, int) 254661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @see #removeTab(Tab) 255661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @see #removeTabAt(int) 256661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 257661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell public abstract void setTabNavigationMode(int containerViewId); 258661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 259661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 260661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * Create and return a new {@link Tab}. 261661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * This tab will not be included in the action bar until it is added. 262661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 263661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @return A new Tab 264661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 265661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @see #addTab(Tab) 266661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @see #insertTab(Tab, int) 267661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 268661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell public abstract Tab newTab(); 269661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 270661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 271661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * Add a tab for use in tabbed navigation mode. The tab will be added at the end of the list. 272661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 273661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @param tab Tab to add 274661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 275661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell public abstract void addTab(Tab tab); 276661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 277661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 278661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * Insert a tab for use in tabbed navigation mode. The tab will be inserted at 279661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * <code>position</code>. 280661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 281661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @param tab The tab to add 282661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @param position The new position of the tab 283661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 284661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell public abstract void insertTab(Tab tab, int position); 285661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 286661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 287661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * Remove a tab from the action bar. 288661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 289661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @param tab The tab to remove 290661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 291661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell public abstract void removeTab(Tab tab); 292661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 293661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 294661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * Remove a tab from the action bar. 295661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 296661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @param position Position of the tab to remove 297661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 298661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell public abstract void removeTabAt(int position); 299661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 300661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 301661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * Select the specified tab. If it is not a child of this action bar it will be added. 302661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 303661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @param tab Tab to select 304661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 305661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell public abstract void selectTab(Tab tab); 306661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 307661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 308661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * Select the tab at <code>position</code> 309661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 310661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @param position Position of the tab to select 311661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 312661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell public abstract void selectTabAt(int position); 313661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 31433b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell /** 31589e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * Represents a contextual mode of the Action Bar. Context modes can be used for 31689e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * modal interactions with activity content and replace the normal Action Bar until finished. 31789e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * Examples of good contextual modes include selection modes, search, content editing, etc. 31833b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell */ 31989e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell public static abstract class ContextMode { 32033b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell /** 32189e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * Set the title of the context mode. This method will have no visible effect if 32289e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * a custom view has been set. 32389e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * 32489e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * @param title Title string to set 32589e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * 32689e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * @see #setCustomView(View) 327a408291e22def5755559f42cde913706a6d628c0Adam Powell */ 32889e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell public abstract void setTitle(CharSequence title); 329a408291e22def5755559f42cde913706a6d628c0Adam Powell 33089e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell /** 33189e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * Set the subtitle of the context mode. This method will have no visible effect if 33289e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * a custom view has been set. 33389e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * 33489e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * @param subtitle Subtitle string to set 33589e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * 33689e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * @see #setCustomView(View) 33733b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell */ 33889e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell public abstract void setSubtitle(CharSequence subtitle); 33989e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell 34089e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell /** 34189e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * Set a custom view for this context mode. The custom view will take the place of 34289e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * the title and subtitle. Useful for things like search boxes. 34389e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * 34489e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * @param view Custom view to use in place of the title/subtitle. 34589e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * 34689e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * @see #setTitle(CharSequence) 34789e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * @see #setSubtitle(CharSequence) 34889e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell */ 34989e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell public abstract void setCustomView(View view); 35089e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell 35189e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell /** 35289e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * Invalidate the context mode and refresh menu content. The context mode's 35389e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * {@link ContextModeCallback} will have its 35489e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * {@link ContextModeCallback#onPrepareContextMode(ContextMode, Menu)} method called. 35589e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * If it returns true the menu will be scanned for updated content and any relevant changes 35689e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * will be reflected to the user. 35789e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell */ 35889e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell public abstract void invalidate(); 35989e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell 36089e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell /** 36189e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * Finish and close this context mode. The context mode's {@link ContextModeCallback} will 36289e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * have its {@link ContextModeCallback#onDestroyContextMode(ContextMode)} method called. 36389e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell */ 36489e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell public abstract void finish(); 36589e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell 36689e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell /** 36789e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * Returns the menu of actions that this context mode presents. 36889e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * @return The context mode's menu. 36989e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell */ 37089e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell public abstract Menu getMenu(); 37133b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell } 37233b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell 37333b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell /** 37489e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * Callback interface for ActionBar context modes. Supplied to 37589e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * {@link ActionBar#startContextMode(ContextModeCallback)}, a ContextModeCallback 37689e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * configures and handles events raised by a user's interaction with a context mode. 37789e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * 37889e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * <p>A context mode's lifecycle is as follows: 37989e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * <ul> 38089e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * <li>{@link ContextModeCallback#onCreateContextMode(ContextMode, Menu)} once on initial 38189e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * creation</li> 38289e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * <li>{@link ContextModeCallback#onPrepareContextMode(ContextMode, Menu)} after creation 38389e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * and any time the {@link ContextMode} is invalidated</li> 38489e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * <li>{@link ContextModeCallback#onContextItemClicked(ContextMode, MenuItem)} any time a 38589e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * contextual action button is clicked</li> 38689e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * <li>{@link ContextModeCallback#onDestroyContextMode(ContextMode)} when the context mode 38789e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * is closed</li> 38889e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * </ul> 38933b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell */ 39089e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell public interface ContextModeCallback { 39189e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell /** 39289e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * Called when a context mode is first created. The menu supplied will be used to generate 39389e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * action buttons for the context mode. 39489e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * 39589e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * @param mode ContextMode being created 39689e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * @param menu Menu used to populate contextual action buttons 39789e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * @return true if the context mode should be created, false if entering this context mode 39889e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * should be aborted. 39989e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell */ 40089e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell public boolean onCreateContextMode(ContextMode mode, Menu menu); 40133b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell 40289e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell /** 40389e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * Called to refresh a context mode's action menu whenever it is invalidated. 40489e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * 40589e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * @param mode ContextMode being prepared 40689e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * @param menu Menu used to populate contextual action buttons 40789e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * @return true if the menu or context mode was updated, false otherwise. 40889e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell */ 40989e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell public boolean onPrepareContextMode(ContextMode mode, Menu menu); 41033b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell 41189e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell /** 41289e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * Called to report a user click on a contextual action button. 41389e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * 41489e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * @param mode The current ContextMode 41589e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * @param item The item that was clicked 41689e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * @return true if this callback handled the event, false if the standard MenuItem 41789e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * invocation should continue. 41889e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell */ 41989e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell public boolean onContextItemClicked(ContextMode mode, MenuItem item); 42089e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell 42189e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell /** 42289e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * Called when a context mode is about to be exited and destroyed. 42389e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * 42489e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * @param mode The current ContextMode being destroyed 42589e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell */ 42689e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell public void onDestroyContextMode(ContextMode mode); 42789e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell } 42889e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell 42989e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell /** 43089e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * Callback interface for ActionBar navigation events. 43189e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell */ 43289e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell public interface NavigationCallback { 43389e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell /** 43489e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * This method is called whenever a navigation item in your action bar 43589e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * is selected. 43689e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * 43789e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * @param itemPosition Position of the item clicked. 43889e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * @param itemId ID of the item clicked. 43989e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell * @return True if the event was handled, false otherwise. 44089e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell */ 44189e0645b4157961e8c465eb9c819f965fdb453d8Adam Powell public boolean onNavigationItemSelected(int itemPosition, long itemId); 44233b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell } 443661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 444661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 445661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * A tab in the action bar. 446661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 447661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * <p>Tabs manage the hiding and showing of {@link Fragment}s. 448661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 449661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell public static abstract class Tab { 450661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 451661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * An invalid position for a tab. 452661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 453661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @see #getPosition() 454661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 455661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell public static final int INVALID_POSITION = -1; 456661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 457661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 458661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * Return the current position of this tab in the action bar. 459661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 460661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @return Current position, or {@link #INVALID_POSITION} if this tab is not currently in 461661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * the action bar. 462661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 463661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell public abstract int getPosition(); 464661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 465661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 466661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * Return the icon associated with this tab. 467661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 468661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @return The tab's icon 469661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 470661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell public abstract Drawable getIcon(); 471661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 472661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 473661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * Return the text of this tab. 474661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 475661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @return The tab's text 476661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 477661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell public abstract CharSequence getText(); 478661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 479661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 480661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * Set the icon displayed on this tab. 481661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 482661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @param icon The drawable to use as an icon 483661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 484661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell public abstract void setIcon(Drawable icon); 485661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 486661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 487661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * Set the text displayed on this tab. Text may be truncated if there is not 488661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * room to display the entire string. 489661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 490661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @param text The text to display 491661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 492661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell public abstract void setText(CharSequence text); 493661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 494661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 495661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * Returns the fragment that will be shown when this tab is selected. 496661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 497661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @return Fragment associated with this tab 498661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 499661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell public abstract Fragment getFragment(); 500661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 501661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 502661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * Set the fragment that will be shown when this tab is selected. 503661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * 504661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * @param fragment Fragment to associate with this tab 505661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 506661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell public abstract void setFragment(Fragment fragment); 507661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell 508661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell /** 509661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell * Select this tab. Only valid if the tab has been added to the action bar. 510661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell */ 511661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell public abstract void select(); 512661c908e4e26c99adc2cab7558a02129eaee059dAdam Powell } 51333b974393b6fadcefc896ec4a0f9b66724f61e9fAdam Powell} 514