API 翻译之 ActionBar

public abstract class

ActionBar        

extends Object         Added in API level 11 

java.lang.Object 

  android.app.ActionBar    位于 Android.app包下。

Class Overview  (类详细描述)


A window feature at the top of the activity that may display the activity title, navigation modes, and other interactive items.

在Activity的顶部,可显示Activity 的标题,导航模式和其他互动的选项。

Beginning with Android 3.0 (API level 11), the action bar appears at the top of an activity's window when the activity uses the system's Holo theme (or one of its descendant themes), which is the default. You may otherwise add the action bar by calling requestFeature(FEATURE_ACTION_BAR) or by declaring it in a custom theme with the windowActionBar property.

自Android 3.0(API等级 11)开始使用,Activity Bar出现在Activity 窗口的顶部,默认使用系统的 Holo主题(或者是Holo的衍生主题)。你必须在代码中使用 requestFeature(FETURE_ACTION_BAR) 或者在自定义的Theme中声明 windoActionBar 的属性,否则将不能使用。

By default, the action bar shows the application icon on the left, followed by the activity title. If your activity has an options menu, you can make select items accessible directly from the action bar as "action items". You can also modify various characteristics of the action bar or remove it completely.

通常情况下,ActionBar的左边会显示app的图标,紧跟着会显示标题,如果你的Activity还有Menu菜单,你可以直接选择,或者下拉选择。你还可以修改各个Item,或者可以将其完全移除。

From your activity, you can retrieve an instance of ActionBar by calling getActionBar().

在你的Activity中,你可以使用 ActionBar mActionBar = getActionBar() 来获取一个当前Activity的ActionBar的实例。

In some cases, the action bar may be overlayed by another bar that enables contextual actions, using an ActionMode. For example, when the user selects one or more items in your activity, you can enable an action mode that offers actions specific to the selected items, with a UI that temporarily replaces the action bar. Although the UI may occupy the same space, the ActionMode APIs are distinct and independent from those for ActionBar.

在某些情况下,ActionBar 会覆盖在另外一个bar中,要想启用这个bar ,可以使用ActionMode()。例如,当用户在你的Activity中点击一个活多个ActionBar的选项时,你可以启动这个ActionMode,提供特定选择的操作方式,UI会提供一个暂时的界面来取代ActionBar。虽然UI占据了一些空间,但ActionMode的API是跟 ActionBar不同的。

Developer Guides  

For information about how to use the action bar, including how to add action items, navigation modes and more, read the Action Bar developer guide.

开发指南
更多关于使用ActionBar,和添加ActionBar 选项以及导航模式,请阅读 ActionBar 的开发指南。

Summary 总览

Nested Classes 内部类
class ActionBar.LayoutParams Per-child layout information associated with action bar custom views. (自定义的ActionBar的布局的详细信息)
interface ActionBar.OnMenuVisibilityListener Listener for receiving events when action bar menus are shown or hidden. (监听ActionBarMenu的隐藏与显示)
interface ActionBar.OnNavigationListener Listener interface for ActionBar navigation events. (监听ActionBar的导航事件)
class ActionBar.Tab A tab in the action bar. (ActionBar的一个选项卡)
interface ActionBar.TabListener Callback interface invoked when a tab is focused, unfocused, added, or removed. (tab的监听器,监听了tab的 focused,added等事件)

Constants

public static final int DISPLAY_HOME_AS_UP

Added in API level 11

Display the 'home' element such that it appears as an 'up' affordance. e.g. show an arrow to the left indicating the action that will be taken. Set this flag if selecting the 'home' button in the action bar to return up by a single level in your UI rather than back to the top level or front page.

Setting this option will implicitly enable interaction with the home/up button. See setHomeButtonEnabled(boolean).

 

显示 一个AppIcon 点击后可以回到App的主页面,紧跟其后是一个标题

 

Constant Value: 4 (0x00000004)

public static final int DISPLAY_SHOW_CUSTOM

Added in API level 11

Show the custom view if one has been set.

此常量可以使用自定义的View

 

Constant Value: 16 (0x00000010)

public static final int DISPLAY_SHOW_HOME

Added in API level 11

Show 'home' elements in this action bar, leaving more space for other navigation elements. This includes logo and icon.

只显示Home,为其他的元素留出空间。

 

Constant Value: 2 (0x00000002)

public static final int DISPLAY_SHOW_TITLE

Added in API level 11

Show the activity title and subtitle, if present.

只显示标题

 

Constant Value: 8 (0x00000008)

public static final int DISPLAY_USE_LOGO

Added in API level 11

Use logo instead of icon if available. This flag will cause appropriate navigation modes to use a wider logo in place of the standard icon.

 

Constant Value: 1 (0x00000001)

public static final int NAVIGATION_MODE_LIST

Added in API level 11

List navigation mode. Instead of static title text this mode presents a list menu for navigation within the activity. e.g. this might be presented to the user as a dropdown list.

Constant Value: 1 (0x00000001)
导航模式会下拉滴列出各个选项

 

public static final int NAVIGATION_MODE_STANDARD

Added in API level 11

Standard navigation mode. Consists of either a logo or icon and title text with an optional subtitle. Clicking any of these elements will dispatch onOptionsItemSelected to the host Activity with a MenuItem with item ID android.R.id.home.

标准的导航模式,我也没弄明白。

 

Constant Value: 0 (0x00000000)

public static final int NAVIGATION_MODE_TABS

Added in API level 11

Tab navigation mode. Instead of static title text this mode presents a series of tabs for navigation within the activity.

使用 Tab 标签页的方式显示。

 

Constant Value: 2 (0x00000002)
 

Public Methods 公用方法

public abstract void addOnMenuVisibilityListener (ActionBar.OnMenuVisibilityListener listener)

Add a listener that will respond to menu visibility change events.
Parameters

listener The new listener to add

 
添加一个Menu显示隐藏的监听器
参数为Listener

 

public abstract void addTab (ActionBar.Tab tab, boolean setSelected)

Added in API level 11

Add a tab for use in tabbed navigation mode. The tab will be added at the end of the list.

Parameters
tab Tab to add
setSelected True if the added tab should become the selected tab.

 

添加标签导航模式,该标签会被加在列表末尾。
参数tab, 是否显示

public abstract void addTab (ActionBar.Tab tab, int position)

Added in API level 11

Add a tab for use in tabbed navigation mode. The tab will be inserted at position. If this is the first tab to be added it will become the selected tab.

为ActionBar 添加一个 tab标签,可以指定添加的标签的顺序。

 

Parameters
tab The tab to add
position The new position of the tab

public abstract void addTab (ActionBar.Tab tab, int position, boolean setSelected)

Added in API level 11

Add a tab for use in tabbed navigation mode. The tab will be insterted at position.

为ActionBar 添加一个 tab标签,可以指定添加的标签的顺序,以及是否显示。

 

Parameters
tab The tab to add
position The new position of the tab
setSelected True if the added tab should become the selected tab.

public abstract void addTab (ActionBar.Tab tab)

Added in API level 11

Add a tab for use in tabbed navigation mode. The tab will be added at the end of the list. If this is the first tab to be added it will become the selected tab.

 

为ActionBar 添加一个 tab标签.将会被添加在末尾,如果是第一个,将会默认选中。

 

Parameters

tab Tab to add

 

public abstract View getCustomView ()

 

获取自定义的View

 

Added in API level 11

 

Returns
  • The current custom view.

public abstract int getDisplayOptions ()

Added in API level 11
获取当前显示的 Options .

 

 
Returns
  • The current set of display options.

public abstract int getHeight ()

Added in API level 11

Retrieve the current height of the ActionBar.

获取当前ActionBar 的高度。

 

Returns
  • The ActionBar's height

public abstract int getNavigationItemCount ()

Added in API level 11

Get the number of navigation items present in the current navigation mode.

获取导航模式选项的个数。

 

Returns
  • Number of navigation items.

public abstract int getNavigationMode ()

Added in API level 11

Returns the current navigation mode. The result will be one of:

 

获取当前的导航模式,有三种NAVIGATION_MODE_STANDARD,NAVIGATION_MODE_LIST,NAVIGATION_MODE_TABS

Returns

  • The current navigation mode.

public abstract int getSelectedNavigationIndex ()

 

Added in API level 11

 

Get the position of the selected navigation item in list or tabbed navigation modes.

获取当前选中的导航模式

 

Returns
  • Position of the selected item.

public abstract ActionBar.Tab getSelectedTab ()

Added in API level 11

Returns the currently selected tab if in tabbed navigation mode and there is at least one tab present.

获取当前选中的Tab标签。

 

Returns
  • The currently selected tab or null

public abstract CharSequence getSubtitle ()

Added in API level 11

Returns the current ActionBar subtitle in standard mode. Returns null if getNavigationMode() would not return NAVIGATION_MODE_STANDARD.

获取当前ActionBar的子标题。

Returns

  • The current ActionBar subtitle or null.

 

public abstract ActionBar.Tab getTabAt (int index)

Added in API level 11

Returns the tab at the specified index.

返回指定的Tab标签,index 即为需要获取的tab的序号.

Parameters

index Index value in the range 0-get

 

public abstract int getTabCount ()

Added in API level 11

Returns the number of tabs currently registered with the action bar.

返回当前ActionBar的数量。

 

Returns
  • Tab count

 public Context getThemedContext ()

Added in API level 14

Returns a Context with an appropriate theme for creating views that will appear in the action bar. If you are inflating or instantiating custom views that will appear in an action bar, you should use the Context returned by this method. (This includes adapters used for list navigation mode.) This will ensure that views contrast properly against the action bar.

返回主题为“创建视图的操作栏将出现在适当的上下文。如果你是inflating或instantiating实例将出现在操作栏的自定义视图时,你应该使用这种方法返回的环境。 (这包括适配器列表导航模式),这将确保正确地对操作栏的对比。

 Returns

 A themed Context for creating views

public abstract CharSequence getTitle ()

Added in API level 11

Returns the current ActionBar title in standard mode. Returns null if getNavigationMode() would not return NAVIGATION_MODE_STANDARD.

在标准模式下,将会返回标题,如果在其他模式下,将会返回null

 

Returns
  • The current ActionBar title or null.

  

public abstract void hide ()

Added in API level 11

Hide the ActionBar if it is currently showing. If the window hosting the ActionBar does not have the feature FEATURE_ACTION_BAR_OVERLAY it will resize application content to fit the new space available.

Instead of calling this function directly, you can also cause an ActionBar using the overlay feature to hide through View.SYSTEM_UI_FLAG_FULLSCREEN. Hiding the ActionBar through this system UI flag allows you to more seamlessly hide it in conjunction with other screen decorations.

如果它目前是显示的,如果这个窗口的ActionBar没有的功能FEATURE_ACTION_BAR_OVERLAY,那么僵会调整界面大小,以适应可以用空间。

 

public abstract boolean isShowing ()

Added in API level 11
 
如果ActionBar显示返回true否则false

 Returns

  • true if the ActionBar is showing, false otherwise.

public abstract ActionBar.Tab newTab ()

Added in API level 11

Create and return a new ActionBar.Tab. This tab will not be included in the action bar until it is added.

Very often tabs will be used to switch between Fragment objects. Here is a typical implementation of such tabs:

 

创建一个 ActionBar 的tab标签,但这个不会被自动添加,需要手动添加。
tab标签需要在多个tab之间切换,下面就是一个典型的实例。
View Code
import android.app.ActionBar;
import android.app.ActionBar.Tab;
import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.widget.Toast;

/**
 * This demonstrates the use of action bar tabs and how they interact
 * with other action bar features.
 */
public class FragmentTabs extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        final ActionBar bar = getActionBar();
        bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
        bar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE);

        bar.addTab(bar.newTab()
                .setText("Simple")
                .setTabListener(new TabListener<FragmentStack.CountingFragment>(
                        this, "simple", FragmentStack.CountingFragment.class)));
        bar.addTab(bar.newTab()
                .setText("Contacts")
                .setTabListener(new TabListener<LoaderCursor.CursorLoaderListFragment>(
                        this, "contacts", LoaderCursor.CursorLoaderListFragment.class)));
        bar.addTab(bar.newTab()
                .setText("Apps")
                .setTabListener(new TabListener<LoaderCustom.AppListFragment>(
                        this, "apps", LoaderCustom.AppListFragment.class)));
        bar.addTab(bar.newTab()
                .setText("Throttle")
                .setTabListener(new TabListener<LoaderThrottle.ThrottledLoaderListFragment>(
                        this, "throttle", LoaderThrottle.ThrottledLoaderListFragment.class)));

        if (savedInstanceState != null) {
            bar.setSelectedNavigationItem(savedInstanceState.getInt("tab", 0));
        }
    }

    @Override
    protected void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        outState.putInt("tab", getActionBar().getSelectedNavigationIndex());
    }

    public static class TabListener<T extends Fragment> implements ActionBar.TabListener {
        private final Activity mActivity;
        private final String mTag;
        private final Class<T> mClass;
        private final Bundle mArgs;
        private Fragment mFragment;

        public TabListener(Activity activity, String tag, Class<T> clz) {
            this(activity, tag, clz, null);
        }

        public TabListener(Activity activity, String tag, Class<T> clz, Bundle args) {
            mActivity = activity;
            mTag = tag;
            mClass = clz;
            mArgs = args;

            // Check to see if we already have a fragment for this tab, probably
            // from a previously saved state.  If so, deactivate it, because our
            // initial state is that a tab isn't shown.
            mFragment = mActivity.getFragmentManager().findFragmentByTag(mTag);
            if (mFragment != null && !mFragment.isDetached()) {
                FragmentTransaction ft = mActivity.getFragmentManager().beginTransaction();
                ft.detach(mFragment);
                ft.commit();
            }
        }

        public void onTabSelected(Tab tab, FragmentTransaction ft) {
            if (mFragment == null) {
                mFragment = Fragment.instantiate(mActivity, mClass.getName(), mArgs);
                ft.add(android.R.id.content, mFragment, mTag);
            } else {
                ft.attach(mFragment);
            }
        }

        public void onTabUnselected(Tab tab, FragmentTransaction ft) {
            if (mFragment != null) {
                ft.detach(mFragment);
            }
        }

        public void onTabReselected(Tab tab, FragmentTransaction ft) {
            Toast.makeText(mActivity, "Reselected!", Toast.LENGTH_SHORT).show();
        }
    }
}
Returns
  • A new Tab
See Also

public abstract void removeAllTabs ()

Added in API level 11

Remove all tabs from the action bar and deselect the current tab.

移除所有的tab标签。

 

public abstract void removeOnMenuVisibilityListener (ActionBar.OnMenuVisibilityListener listener)

Added in API level 11

Remove a menu visibility listener. This listener will no longer receive menu visibility change events.

移除一个Menu 显示的监听器,此监听器将不再监听tab显示的变换。

 

Parameters
listener A listener to remove that was previously added

 

public abstract void removeTab (ActionBar.Tab tab)

Added in API level 11

Remove a tab from the action bar. If the removed tab was selected it will be deselected and another tab will be selected if present.

删除ActionBar的一个标签,如果删除的这个tab标签是选中的,那么删除后,将会选择另外一个。

 

Parameters
tab The tab to remove

 

public abstract void removeTabAt (int position)

Added in API level 11

Remove a tab from the action bar. If the removed tab was selected it will be deselected and another tab will be selected if present.

删除ActionBar的一个标签,如果删除的这个tab标签是选中的,那么删除后,将会选择另外一个。 

Parameters

tab The tab to remove

 

ublic abstract void removeTabAt (int position)

Added in API level 11

Remove a tab from the action bar. If the removed tab was selected it will be deselected and another tab will be selected if present.

删除ActionBar的一个标签,如果删除的这个tab标签是选中的,那么删除后,将会选择另外一个。  
Parameters
position Position of the tab to remove

 

 

public abstract void selectTab (ActionBar.Tab tab)

Added in API level 11

Select the specified tab. If it is not a child of this action bar it will be added.

Note: If you want to select by index, use setSelectedNavigationItem(int)

选中一个指定的tab标签,如果这个不是子控件,将会被添加到ActionBar,如果你想选中指定的,可以使用setSelectedNavigationItem(int).

 

Parameters

tabTab to select

 

public abstract void setBackgroundDrawable (Drawable d)

Added in API level 11

Set the ActionBar's background. This will be used for the primary action bar.

设置ActionBar的背景色。

 

Parameters
d Background drawable

 

public abstract void setCustomView (int resId)

Added in API level 11

Set the action bar into custom navigation mode, supplying a view for custom navigation.

Custom navigation views appear between the application icon and any action buttons and may use any space available there. Common use cases for custom navigation views might include an auto-suggesting address bar for a browser or other navigation mechanisms that do not translate well to provided navigation modes.

The display option DISPLAY_SHOW_CUSTOM must be set for the custom view to be displayed. 

将操作模式设置为自定义的导航模式,提供一个自定义的导航视图。
自定义的导航可以使用Icon,以及任何空间,共同使用自定义导航的视图的情况下,可能会包括一个自动提示的地址栏的浏览器或其他的导航机制,不能很好地提供导航模式。
必须要设置显示的属性为  DISPLAY_SHOW_CUSTOM 否则将无法显示自定义的视图。

Parameters

resId Resource ID of a layout to inflate into the ActionBar.

 

public abstract void setCustomView (View view)

Added in API level 11

Set the action bar into custom navigation mode, supplying a view for custom navigation. Custom navigation views appear between the application icon and any action buttons and may use any space available there. Common use cases for custom navigation views might include an auto-suggesting address bar for a browser or other navigation mechanisms that do not translate well to provided navigation modes.

将操作模式设置为自定义的导航模式,提供一个自定义的导航视图。
自定义的导航可以使用Icon,以及任何空间,共同使用自定义导航的视图的情况下,可能会包括一个自动提示的地址栏的浏览器或其他的导航机制,不能很好地提供导航模式。
必须要设置显示的属性为  DISPLAY_SHOW_CUSTOM 否则将无法显示自定义的视图。
 
Parameters
view Custom navigation view to place in the ActionBar.

 

public abstract void setCustomView (View view, ActionBar.LayoutParams layoutParams)

Added in API level 11

Set the action bar into custom navigation mode, supplying a view for custom navigation.

Custom navigation views appear between the application icon and any action buttons and may use any space available there. Common use cases for custom navigation views might include an auto-suggesting address bar for a browser or other navigation mechanisms that do not translate well to provided navigation modes.

The display option DISPLAY_SHOW_CUSTOM must be set for the custom view to be displayed.

 

将操作模式设置为自定义的导航模式,提供一个自定义的导航视图。
自定义的导航可以使用Icon,以及任何空间,共同使用自定义导航的视图的情况下,可能会包括一个自动提示的地址栏的浏览器或其他的导航机制,不能很好地提供导航模式。
可以指定要显示的详细信息。
必须要设置显示的属性为  DISPLAY_SHOW_CUSTOM 否则将无法显示自定义的视图。
 
Parameters
view Custom navigation view to place in the ActionBar.
layoutParams How this custom view should layout in the bar.

 

public abstract void setDisplayHomeAsUpEnabled (boolean showHomeAsUp)

Added in API level 11

Set whether home should be displayed as an "up" affordance. Set this to true if selecting "home" returns up by a single level in your UI rather than back to the top level or front page.

To set several display options at once, see the setDisplayOptions methods.

设置是否要点击appIcon的时候回到上个页面。可以参考setDisplayOptions方法。

 

Parameters
showHomeAsUp true to show the user that selecting home will return one level up rather than to the top level of the app.

public abstract void setDisplayOptions (int options, int mask)

Added in API level 11

Set selected display options. Only the options specified by mask will be changed. To change all display option bits at once, see setDisplayOptions(int).

Example: setDisplayOptions(0, DISPLAY_SHOW_HOME) will disable the DISPLAY_SHOW_HOME option. setDisplayOptions(DISPLAY_SHOW_HOME, DISPLAY_SHOW_HOME | DISPLAY_USE_LOGO) will enable DISPLAY_SHOW_HOME and disable DISPLAY_USE_LOGO.

设置所选的显示选项。只有通过掩膜指定的选项将被改变。要改变所有显示选项位,请参阅 setDisplayOptions(int)
例如:要显示DISPLAY_SHOW_HOME 就可以 setDisplayOptions(0, DISPLAY_SHOW_HOME), setDisplayOptions(DISPLAY_SHOW_HOME, DISPLAY_SHOW_HOME | DISPLAY_USE_LOGO) 将会启用 DISPLAY_SHOW_HOME 
和 DISPLAY_USE_LOGO.

 

Parameters
options A combination of the bits defined by the DISPLAY_ constants defined in ActionBar.
mask A bit mask declaring which display options should be changed.

 

 

public abstract void setDisplayOptions (int options)

Added in API level 11

Set display options. This changes all display option bits at once. To change a limited subset of display options, see  setDisplayOptions(int, int)

设置显示选项,这改变了这所有的显示选项位。要改变一个有限子集的显示选项, setDisplayOptions(int, int)

 

Parameters

options A combination of the bits defined by the DISPLAY_ constants defined in ActionBar.

 

public abstract void setDisplayShowCustomEnabled (boolean showCustom)

Added in API level 11

Set whether a custom view should be displayed, if set.

To set several display options at once, see the setDisplayOptions methods.

设置一个自定义视图是否显示。要设置多个选项卡,请看 setDisplayOptions 方法。

 

Parameters
showCustom true if the currently set custom view should be displayed, false otherwise.

public abstract void setDisplayShowHomeEnabled (boolean showHome)

Added in API level 11

Set whether to include the application home affordance in the action bar. Home is presented as either an activity icon or logo.

To set several display options at once, see the setDisplayOptions methods.

设置一个自定义视图是否显示。要设置多个选项卡,请看 setDisplayOptions 方法。 

Parameters

showHome true to show home, false otherwise.

public abstract void setDisplayShowTitleEnabled (boolean showTitle)

Added in API level 11

Set whether an activity title/subtitle should be displayed.

To set several display options at once, see the setDisplayOptions methods.

设置是否显示标题。在操作栏中的应用程序的主页。首页的活动图标或标识。

 

Parameters
showTitle true to display a title/subtitle if present.

public abstract void setDisplayUseLogoEnabled (boolean useLogo)

Added in API level 11

Set whether to display the activity logo rather than the activity icon. A logo is often a wider, more detailed image.

To set several display options at once, see the setDisplayOptions methods.

设置的活动是否应显示的标题。

 

Parameters
useLogo true to use the activity logo, false to use the activity icon.

public void setHomeButtonEnabled (boolean enabled)

Added in API level 14

Enable or disable the "home" button in the corner of the action bar. (Note that this is the application home/up affordance on the action bar, not the systemwide home button.)

This defaults to true for packages targeting < API 14. For packages targeting API 14 or greater, the application should call this method to enable interaction with the home/up affordance.

Setting the DISPLAY_HOME_AS_UP display option will automatically enable the home button.

设置 Home键是否启用

 

Parameters
enabled true to enable the home button, false to disable the home button.

public abstract void setIcon (Drawable icon)

Added in API level 14

Set the icon to display in the 'home' section of the action bar. The action bar will use an icon specified by its style or the activity icon by default. Whether the home section shows an icon or logo is controlled by the display option DISPLAY_USE_LOGO.

设置ActionBar要显示的Icon

 

Parameters
icon Drawable to show as an icon.

public abstract void setIcon (int resId)

Added in API level 14

Set the icon to display in the 'home' section of the action bar. The action bar will use an icon specified by its style or the activity icon by default. Whether the home section shows an icon or logo is controlled by the display option DISPLAY_USE_LOGO.

设置ActionBar要显示的Icon 

 Parameters

resId Resource ID of a drawable to show as an icon.

public abstract void setListNavigationCallbacks (SpinnerAdapter adapter, ActionBar.OnNavigationListener callback)

Added in API level 11

Set the adapter and navigation callback for list navigation mode. The supplied adapter will provide views for the expanded list as well as the currently selected item. (These may be displayed differently.) The supplied OnNavigationListener will alert the application when the user changes the current list selection.

设置适配器和导航列表导航模式的回调。随机提供的适配器将在展开的列表以及当前选定的项目提供意见。 (它们可能以不同的方式显示。)所提供的OnNavigationListener应用程序时,会提醒用户改变当前列表中选择。

 

Parameters
adapter An adapter that will provide views both to display the current navigation selection and populate views within the dropdown navigation menu.
callback An OnNavigationListener that will receive events when the user selects a navigation item.

public abstract void setLogo (int resId)

Added in API level 14

Set the logo to display in the 'home' section of the action bar. The action bar will use a logo specified by its style or the activity logo by default. Whether the home section shows an icon or logo is controlled by the display option DISPLAY_USE_LOGO.

在操作栏中的“家”节中设置的标志来显示。操作栏将使用默认情况下,它的风格或活动标志的标志。无论是家庭部分将显示一个图标或标志由显示选项DISPLAY_USE_LOGO的控制。

 

Parameters
resId Resource ID of a drawable to show as a logo.

public abstract void setLogo (Drawable logo)

Added in API level 14

Set the logo to display in the 'home' section of the action bar. The action bar will use a logo specified by its style or the activity logo by default. Whether the home section shows an icon or logo is controlled by the display option DISPLAY_USE_LOGO.

在操作栏中的“家”节中设置的标志来显示。操作栏将使用默认情况下,它的风格或活动标志的标志。无论是家庭部分将显示一个图标或标志由显示选项DISPLAY_USE_LOGO的控制。 

 Parameters

logo Drawable to show as a logo.

public abstract void setNavigationMode (int mode)

Added in API level 11

Set the current navigation mode.

设置当前的导航模式

 

Parameters
mode The new mode to set.

public abstract void setSelectedNavigationItem (int position)

Added in API level 11

Set the selected navigation item in list or tabbed navigation modes.

设置当前的导航模式,list 或者 tab的。

 Parameters

position Position of the item to select.

 

public void setSplitBackgroundDrawable (Drawable d)

Added in API level 14

Set the ActionBar's split background. This will appear in the split action bar containing menu-provided action buttons on some devices and configurations.

You can enable split action bar with uiOptions

设置背景的ActionBar的分裂。这将出现在拆分操作栏,菜单提供一些设备和配置的操作按钮。您可以启用分裂行动吧uiOptions

 

Parameters
d Background drawable for the split bar

 

public void setStackedBackgroundDrawable (Drawable d)

Added in API level 14

Set the ActionBar's stacked background. This will appear in the second row/stacked bar on some devices and configurations.

设置的ActionBar的堆积背景。这将显示在第二行/堆叠栏上的一些设备和配置。

 

Parameters
d Background drawable for the stacked row

public abstract void setSubtitle (int resId)

Added in API level 11

Set the action bar's subtitle. This will only be displayed if DISPLAY_SHOW_TITLE is set.

设置的ActionBar的子标题

 

Parameters
resId Resource ID of subtitle string to set

public abstract void setSubtitle (CharSequence subtitle)

Added in API level 11

Set the action bar's subtitle. This will only be displayed if DISPLAY_SHOW_TITLE is set. Set to null to disable the subtitle entirely.

设置的ActionBar的子标题。

 

Parameters
subtitle Subtitle to set

public abstract void setTitle (int resId)

Added in API level 11

Set the action bar's title. This will only be displayed if DISPLAY_SHOW_TITLE is set.

设置的ActionBar的标题。

 

Parameters
resId Resource ID of title string to set

public abstract void setTitle (CharSequence title)

Added in API level 11

Set the action bar's title. This will only be displayed if DISPLAY_SHOW_TITLE is set.

设置的ActionBar的标题。

 

Parameters
title Title to set

public abstract void show ()

Added in API level 11

Show the ActionBar if it is not currently showing. If the window hosting the ActionBar does not have the feature FEATURE_ACTION_BAR_OVERLAY it will resize application content to fit the new space available.

If you are hiding the ActionBar through View.SYSTEM_UI_FLAG_FULLSCREEN, you should not call this function directly.

 

如果它没有显示在ActionBar目前显示。如果窗口托管的ActionBar没有的功能FEATURE_ACTION_BAR_OVERLAY,将调整应用程序的内容,以适应新的可用空间。如果你隐瞒的ActionBar通过View.SYSTEM_UI_FLAG_FULLSCREEN,你不应该直接调用这个函数。

 

(完) 

 

 

 

posted @ 2013-03-23 12:03  坑坑kk  阅读(965)  评论(0编辑  收藏  举报