Merge "Add support for setting action bar title/subtitle by resource ID"

This commit is contained in:
Adam Powell
2010-07-28 18:10:06 -07:00
committed by Android (Google) Code Review
3 changed files with 140 additions and 0 deletions

View File

@@ -19835,6 +19835,21 @@
deprecated="not deprecated"
visibility="public"
>
<parameter name="titleResId" type="int">
</parameter>
<parameter name="subtitleResId" type="int">
</parameter>
</method>
<method name="setStandardNavigationMode"
return="void"
abstract="true"
native="false"
synchronized="false"
static="false"
final="false"
deprecated="not deprecated"
visibility="public"
>
<parameter name="title" type="java.lang.CharSequence">
</parameter>
</method>
@@ -19848,6 +19863,19 @@
deprecated="not deprecated"
visibility="public"
>
<parameter name="titleResId" type="int">
</parameter>
</method>
<method name="setStandardNavigationMode"
return="void"
abstract="true"
native="false"
synchronized="false"
static="false"
final="false"
deprecated="not deprecated"
visibility="public"
>
</method>
<method name="setSubtitle"
return="void"
@@ -19862,6 +19890,19 @@
<parameter name="subtitle" type="java.lang.CharSequence">
</parameter>
</method>
<method name="setSubtitle"
return="void"
abstract="true"
native="false"
synchronized="false"
static="false"
final="false"
deprecated="not deprecated"
visibility="public"
>
<parameter name="resId" type="int">
</parameter>
</method>
<method name="setTabNavigationMode"
return="void"
abstract="true"
@@ -19899,6 +19940,19 @@
<parameter name="title" type="java.lang.CharSequence">
</parameter>
</method>
<method name="setTitle"
return="void"
abstract="true"
native="false"
synchronized="false"
static="false"
final="false"
deprecated="not deprecated"
visibility="public"
>
<parameter name="resId" type="int">
</parameter>
</method>
<field name="DISPLAY_HIDE_HOME"
type="int"
transient="false"

View File

@@ -131,9 +131,32 @@ public abstract class ActionBar {
*
* @param title The action bar's title. null is treated as an empty string.
* @param subtitle The action bar's subtitle. null will remove the subtitle entirely.
*
* @see #setStandardNavigationMode()
* @see #setStandardNavigationMode(CharSequence)
* @see #setStandardNavigationMode(int)
* @see #setStandardNavigationMode(int, int)
*/
public abstract void setStandardNavigationMode(CharSequence title, CharSequence subtitle);
/**
* Set the action bar into standard navigation mode, supplying a title and subtitle.
*
* Standard navigation mode is default. The title is automatically set to the
* name of your Activity. Subtitles are displayed underneath the title, usually
* in a smaller font or otherwise less prominently than the title. Subtitles are
* good for extended descriptions of activity state.
*
* @param titleResId Resource ID of a title string
* @param subtitleResId Resource ID of a subtitle string
*
* @see #setStandardNavigationMode()
* @see #setStandardNavigationMode(CharSequence)
* @see #setStandardNavigationMode(CharSequence, CharSequence)
* @see #setStandardNavigationMode(int)
*/
public abstract void setStandardNavigationMode(int titleResId, int subtitleResId);
/**
* Set the action bar into standard navigation mode, supplying a title and subtitle.
*
@@ -141,9 +164,29 @@ public abstract class ActionBar {
* name of your Activity on startup if an action bar is present.
*
* @param title The action bar's title. null is treated as an empty string.
*
* @see #setStandardNavigationMode()
* @see #setStandardNavigationMode(CharSequence, CharSequence)
* @see #setStandardNavigationMode(int)
* @see #setStandardNavigationMode(int, int)
*/
public abstract void setStandardNavigationMode(CharSequence title);
/**
* Set the action bar into standard navigation mode, supplying a title and subtitle.
*
* Standard navigation mode is default. The title is automatically set to the
* name of your Activity on startup if an action bar is present.
*
* @param titleResId Resource ID of a title string
*
* @see #setStandardNavigationMode()
* @see #setStandardNavigationMode(CharSequence)
* @see #setStandardNavigationMode(CharSequence, CharSequence)
* @see #setStandardNavigationMode(int, int)
*/
public abstract void setStandardNavigationMode(int titleResId);
/**
* Set the action bar into standard navigation mode, using the currently set title
* and/or subtitle.
@@ -157,17 +200,39 @@ public abstract class ActionBar {
* Set the action bar's title. This will only be displayed in standard navigation mode.
*
* @param title Title to set
*
* @see #setTitle(int)
*/
public abstract void setTitle(CharSequence title);
/**
* Set the action bar's title. This will only be displayed in standard navigation mode.
*
* @param resId Resource ID of title string to set
*
* @see #setTitle(CharSequence)
*/
public abstract void setTitle(int resId);
/**
* Set the action bar's subtitle. This will only be displayed in standard navigation mode.
* Set to null to disable the subtitle entirely.
*
* @param subtitle Subtitle to set
*
* @see #setSubtitle(int)
*/
public abstract void setSubtitle(CharSequence subtitle);
/**
* Set the action bar's subtitle. This will only be displayed in standard navigation mode.
*
* @param resId Resource ID of subtitle string to set
*
* @see #setSubtitle(CharSequence)
*/
public abstract void setSubtitle(int resId);
/**
* Set display options. This changes all display option bits at once. To change
* a limited subset of display options, see {@link #setDisplayOptions(int, int)}.

View File

@@ -106,6 +106,27 @@ public class ActionBarImpl extends ActionBar {
CONTEXT_DISPLAY_NORMAL : CONTEXT_DISPLAY_SPLIT;
}
@Override
public void setStandardNavigationMode(int titleResId, int subtitleResId) {
setStandardNavigationMode(mActivity.getString(titleResId),
mActivity.getString(subtitleResId));
}
@Override
public void setStandardNavigationMode(int titleResId) {
setStandardNavigationMode(mActivity.getString(titleResId));
}
@Override
public void setTitle(int resId) {
setTitle(mActivity.getString(resId));
}
@Override
public void setSubtitle(int resId) {
setSubtitle(mActivity.getString(resId));
}
public void setCustomNavigationMode(View view) {
cleanupTabs();
mActionView.setCustomNavigationView(view);