summaryrefslogtreecommitdiff
path: root/core/java/android
diff options
context:
space:
mode:
authorAdam Powell <adamp@google.com>2011-01-03 19:25:36 -0800
committerAdam Powell <adamp@google.com>2011-01-05 11:41:26 -0800
commit3f476b34049d062942eafcf48396f593e00bd324 (patch)
treee6ef24bea8c37eee321a18503c2b018bcfeb077f /core/java/android
parenteb492a02fd5a95f7e3fbf796fdda9e0d82cc15a4 (diff)
Revisiting ActionBar API and layout.
Fix several bugs where ActionBar was ignoring LayoutParams in action views. Add convenience methods for toggling display options flags. Add layout resource version of ActionBar#setCustomView Fix a bug preventing actionViewClasses from being loaded properly in menu xml. Change-Id: I0d9a0b635fd9cfc020bac69369c0c7749c226349
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/app/ActionBar.java86
-rw-r--r--core/java/android/view/MenuInflater.java6
-rw-r--r--core/java/android/view/MenuItem.java12
3 files changed, 100 insertions, 4 deletions
diff --git a/core/java/android/app/ActionBar.java b/core/java/android/app/ActionBar.java
index 67eb02df26d5..8d5a6da9a090 100644
--- a/core/java/android/app/ActionBar.java
+++ b/core/java/android/app/ActionBar.java
@@ -154,6 +154,25 @@ public abstract class ActionBar {
public abstract void setCustomView(View view, LayoutParams layoutParams);
/**
+ * Set the action bar into custom navigation mode, supplying a view
+ * for custom navigation.
+ *
+ * <p>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.</p>
+ *
+ * <p>The display option {@link #DISPLAY_SHOW_CUSTOM} must be set for
+ * the custom view to be displayed.</p>
+ *
+ * @param resId Resource ID of a layout to inflate into the ActionBar.
+ *
+ * @see #setDisplayOptions(int, int)
+ */
+ public abstract void setCustomView(int resId);
+
+ /**
* @param view
* @deprecated Use {@link #setCustomView(View)} and {@link #setDisplayOptions(int)} instead.
*/
@@ -319,7 +338,72 @@ public abstract class ActionBar {
* @param mask A bit mask declaring which display options should be changed.
*/
public abstract void setDisplayOptions(int options, int mask);
-
+
+ /**
+ * Set whether to display the activity logo rather than the activity icon.
+ * A logo is often a wider, more detailed image.
+ *
+ * <p>To set several display options at once, see the setDisplayOptions methods.
+ *
+ * @param useLogo true to use the activity logo, false to use the activity icon.
+ *
+ * @see #setDisplayOptions(int)
+ * @see #setDisplayOptions(int, int)
+ */
+ public abstract void setDisplayUseLogoEnabled(boolean useLogo);
+
+ /**
+ * Set whether to include the application home affordance in the action bar.
+ * Home is presented as either an activity icon or logo.
+ *
+ * <p>To set several display options at once, see the setDisplayOptions methods.
+ *
+ * @param showHome true to show home, false otherwise.
+ *
+ * @see #setDisplayOptions(int)
+ * @see #setDisplayOptions(int, int)
+ */
+ public abstract void setDisplayShowHomeEnabled(boolean showHome);
+
+ /**
+ * 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.
+ *
+ * <p>To set several display options at once, see the setDisplayOptions methods.
+ *
+ * @param showHomeAsUp true to show the user that selecting home will return one
+ * level up rather than to the top level of the app.
+ *
+ * @see #setDisplayOptions(int)
+ * @see #setDisplayOptions(int, int)
+ */
+ public abstract void setDisplayHomeAsUpEnabled(boolean showHomeAsUp);
+
+ /**
+ * Set whether an activity title/subtitle should be displayed.
+ *
+ * <p>To set several display options at once, see the setDisplayOptions methods.
+ *
+ * @param showTitle true to display a title/subtitle if present.
+ *
+ * @see #setDisplayOptions(int)
+ * @see #setDisplayOptions(int, int)
+ */
+ public abstract void setDisplayShowTitleEnabled(boolean showTitle);
+
+ /**
+ * Set whether a custom view should be displayed, if set.
+ *
+ * <p>To set several display options at once, see the setDisplayOptions methods.
+ *
+ * @param showCustom true if the currently set custom view should be displayed, false otherwise.
+ *
+ * @see #setDisplayOptions(int)
+ * @see #setDisplayOptions(int, int)
+ */
+ public abstract void setDisplayShowCustomEnabled(boolean showCustom);
+
/**
* Set the ActionBar's background.
*
diff --git a/core/java/android/view/MenuInflater.java b/core/java/android/view/MenuInflater.java
index 7d5dcd86d1b0..ab515c9f6bbf 100644
--- a/core/java/android/view/MenuInflater.java
+++ b/core/java/android/view/MenuInflater.java
@@ -379,15 +379,15 @@ public class MenuInflater {
if (itemActionViewClassName != null) {
try {
- final Class<?> clazz = Class.forName(itemActionViewClassName);
+ final Class<?> clazz = Class.forName(itemActionViewClassName, true,
+ mContext.getClassLoader());
Constructor<?> c = clazz.getConstructor(ACTION_VIEW_CONSTRUCTOR_SIGNATURE);
item.setActionView((View) c.newInstance(mContext));
} catch (Exception e) {
throw new InflateException(e);
}
} else if (itemActionViewLayout > 0) {
- final LayoutInflater inflater = LayoutInflater.from(mContext);
- item.setActionView(inflater.inflate(itemActionViewLayout, null));
+ item.setActionView(itemActionViewLayout);
}
}
diff --git a/core/java/android/view/MenuItem.java b/core/java/android/view/MenuItem.java
index 602c7654dfc4..780c52ed6440 100644
--- a/core/java/android/view/MenuItem.java
+++ b/core/java/android/view/MenuItem.java
@@ -433,6 +433,18 @@ public interface MenuItem {
public MenuItem setActionView(View view);
/**
+ * Set an action view for this menu item. An action view will be displayed in place
+ * of an automatically generated menu item element in the UI when this item is shown
+ * as an action within a parent.
+ *
+ * @param resId Layout resource to use for presenting this item to the user.
+ * @return This Item so additional setters can be called.
+ *
+ * @see #setShowAsAction(int)
+ */
+ public MenuItem setActionView(int resId);
+
+ /**
* Returns the currently set action view for this menu item.
*
* @return This item's action view