Merge "docs: Removed ActionBar API guide" into mnc-docs
This commit is contained in:
committed by
Android (Google) Code Review
commit
07aa83c9fe
@@ -19,7 +19,7 @@ parent.link=activities.html
|
||||
<li><a href="#CommunicatingWithActivity">Communicating with the Activity</a>
|
||||
<ol>
|
||||
<li><a href="#EventCallbacks">Creating event callbacks to the activity</a></li>
|
||||
<li><a href="#ActionBar">Adding items to the Action Bar</a></li>
|
||||
<li><a href="#ActionBar">Adding items to the App Bar</a></li>
|
||||
</ol>
|
||||
</li>
|
||||
<li><a href="#Lifecycle">Handling the Fragment Lifecycle</a>
|
||||
@@ -603,11 +603,11 @@ href="{@docRoot}guide/topics/providers/content-providers.html">Content Providers
|
||||
|
||||
|
||||
|
||||
<h3 id="ActionBar">Adding items to the Action Bar</h3>
|
||||
<h3 id="ActionBar">Adding items to the App Bar</h3>
|
||||
|
||||
<p>Your fragments can contribute menu items to the activity's <a
|
||||
href="{@docRoot}guide/topics/ui/menus.html#options-menu">Options Menu</a> (and, consequently, the <a
|
||||
href="{@docRoot}guide/topics/ui/actionbar.html">Action Bar</a>) by implementing
|
||||
href="{@docRoot}training/appbar/index.html">app bar</a>) by implementing
|
||||
{@link android.app.Fragment#onCreateOptionsMenu(Menu,MenuInflater) onCreateOptionsMenu()}. In order
|
||||
for this method to receive calls, however, you must call {@link
|
||||
android.app.Fragment#setHasOptionsMenu(boolean) setHasOptionsMenu()} during {@link
|
||||
@@ -634,8 +634,8 @@ handle the selected item, then the event is passed to the fragment's callback. T
|
||||
the Options Menu and context menus.</p>
|
||||
|
||||
<p>For more information about menus, see the <a
|
||||
href="{@docRoot}guide/topics/ui/menus.html">Menus</a> and <a
|
||||
href="{@docRoot}guide/topics/ui/actionbar.html">Action Bar</a> developer guides.</p>
|
||||
href="{@docRoot}guide/topics/ui/menus.html">Menus</a> developer guide and the <a
|
||||
href="{@docRoot}training/appbar/index.html">App Bar</a> training class.</p>
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -262,9 +262,6 @@
|
||||
<li><a href="<?cs var:toroot ?>guide/topics/ui/menus.html">
|
||||
<span class="en">Menus</span></span>
|
||||
</a></li>
|
||||
<li><a href="<?cs var:toroot ?>guide/topics/ui/actionbar.html">
|
||||
<span class="en">Action Bar</span>
|
||||
</a></li>
|
||||
<li><a href="<?cs var:toroot ?>guide/topics/ui/settings.html">
|
||||
<span class="en">Settings</span>
|
||||
</a></li>
|
||||
|
||||
@@ -982,16 +982,17 @@ href="{@docRoot}guide/topics/ui/themes.html">Styles and Themes</a> developer gui
|
||||
<tr><th>Value</th><th>Description</th></tr>
|
||||
<tr><td>{@code "none"}</td><td>No extra UI options. This is the default.</td></tr>
|
||||
<tr><td>{@code "splitActionBarWhenNarrow"}</td><td>Add a bar at
|
||||
the bottom of the screen to display action items in the {@link android.app.ActionBar}, when
|
||||
the bottom of the screen to display action items in the <em>app bar</em> (also known as the
|
||||
<em>action bar</em>), when
|
||||
constrained for horizontal space (such as when in portrait mode on a handset). Instead of a small
|
||||
number of action items appearing in the action bar at the top of the screen, the action bar is
|
||||
number of action items appearing in the app bar at the top of the screen, the app bar is
|
||||
split into the top navigation section and the bottom bar for action items. This ensures a reasonable
|
||||
amount of space is made available not only for the action items, but also for navigation and title
|
||||
elements at the top. Menu items are not split across the two bars; they always appear
|
||||
together.</td></tr>
|
||||
</table>
|
||||
<p>For more information about the action bar, see the <a
|
||||
href="{@docRoot}guide/topics/ui/actionbar.html">Action Bar</a> developer guide.</p>
|
||||
<p>For more information about the app bar, see the <a
|
||||
href="{@docRoot}training/appbar/index.html">Adding the App Bar</a> training class.</p>
|
||||
<p>This attribute was added in API level 14.</p>
|
||||
</dd>
|
||||
|
||||
|
||||
@@ -434,16 +434,17 @@ href="{@docRoot}guide/topics/ui/themes.html">Styles and Themes</a> developer gui
|
||||
<tr><th>Value</th><th>Description</th></tr>
|
||||
<tr><td>{@code "none"}</td><td>No extra UI options. This is the default.</td></tr>
|
||||
<tr><td>{@code "splitActionBarWhenNarrow"}</td><td>Add a bar at
|
||||
the bottom of the screen to display action items in the {@link android.app.ActionBar}, when
|
||||
the bottom of the screen to display action items in the <em>app bar</em> (also known as the
|
||||
<em>action bar</em>), when
|
||||
constrained for horizontal space (such as when in portrait mode on a handset). Instead of a small
|
||||
number of action items appearing in the action bar at the top of the screen, the action bar is
|
||||
number of action items appearing in the app bar at the top of the screen, the app bar is
|
||||
split into the top navigation section and the bottom bar for action items. This ensures a reasonable
|
||||
amount of space is made available not only for the action items, but also for navigation and title
|
||||
elements at the top. Menu items are not split across the two bars; they always appear
|
||||
together.</td></tr>
|
||||
</table>
|
||||
<p>For more information about the action bar, see the <a
|
||||
href="{@docRoot}guide/topics/ui/actionbar.html">Action Bar</a> developer guide.</p>
|
||||
<p>For more information about the app bar, see the <a
|
||||
href="{@docRoot}training/appbar/index.html">Adding the App Bar</a> training class.</p>
|
||||
<p>This attribute was added in API level 14.</p>
|
||||
</dd>
|
||||
|
||||
|
||||
@@ -117,47 +117,47 @@ functionality.</p>
|
||||
<p>Introduced in API Level 11.</p></dd>
|
||||
|
||||
<dt><code>android:showAsAction</code></dt>
|
||||
<dd><em>Keyword</em>. When and how this item should appear as an action item in the Action
|
||||
Bar. A menu item can appear as an action item only when the activity includes an {@link
|
||||
android.app.ActionBar} (introduced in API Level 11). Valid values:
|
||||
<dd><em>Keyword</em>. When and how this item should appear as an action item in the app
|
||||
bar. A menu item can appear as an action item only when the activity includes an
|
||||
app bar. Valid values:
|
||||
<table>
|
||||
<tr><th>Value</th><th>Description</th></tr>
|
||||
<tr><td><code>ifRoom</code></td><td>Only place this item in the
|
||||
Action Bar if there is room for it. If there is not room for all
|
||||
app bar if there is room for it. If there is not room for all
|
||||
the items marked <code>"ifRoom"</code>, the items with the lowest
|
||||
<code>orderInCategory</code> values are displayed as actions, and
|
||||
the remaining items are displayed in the overflow menu.</td></tr>
|
||||
<tr><td><code>withText</code></td><td>Also include the title text (defined
|
||||
by {@code android:title}) with the action item. You can include this value along with one
|
||||
of the others as a flag set, by separating them with a pipe {@code |}.</td></tr>
|
||||
<tr><td><code>never</code></td><td>Never place this item in the Action Bar. Instead, list the item in the Action Bar's overflow
|
||||
<tr><td><code>never</code></td><td>Never place this item in the app bar. Instead, list the item in the app bar's overflow
|
||||
menu.</td></tr>
|
||||
<tr><td><code>always</code></td><td>Always place this item in the Action Bar.
|
||||
<tr><td><code>always</code></td><td>Always place this item in the app bar.
|
||||
Avoid using this unless it's critical that the item always appear in the action
|
||||
bar. Setting multiple items to always appear as action items can result in them overlapping
|
||||
with other UI in the action bar.</td></tr>
|
||||
with other UI in the app bar.</td></tr>
|
||||
<tr><td><code>collapseActionView</code></td><td>The action view associated
|
||||
with this action item (as declared by <code>android:actionLayout</code> or
|
||||
<code>android:actionViewClass</code>) is
|
||||
collapsible.<br/>Introduced in API Level 14.</td></tr>
|
||||
</table>
|
||||
<p>See the <a href="{@docRoot}guide/topics/ui/actionbar.html">Action Bar</a> developer
|
||||
guide for more information.</p>
|
||||
<p>See the <a href="{@docRoot}training/appbar/index.html">Adding the App Bar</a>
|
||||
training class for more information.</p>
|
||||
<p>Introduced in API Level 11.</p>
|
||||
</dd>
|
||||
|
||||
<dt><code>android:actionLayout</code></dt>
|
||||
<dd><em>Layout resource</em>. A layout to use as the action view.
|
||||
<p>See the <a href="{@docRoot}guide/topics/ui/actionbar.html">Action Bar</a> developer
|
||||
guide for more information.</p>
|
||||
<p>See <a href="{@docRoot}training/appbar/action-views.html">Action
|
||||
Views and Action Providers</a> for more information.</p>
|
||||
<p>Introduced in API Level 11.</p></dd>
|
||||
|
||||
<dt><code>android:actionViewClass</code></dt>
|
||||
<dd><em>Class name</em>. A fully-qualified class name for the {@link android.view.View}
|
||||
to use as the action view. For example,
|
||||
{@code "android.widget.SearchView"} to use {@link android.widget.SearchView} as an action view.
|
||||
<p>See the <a href="{@docRoot}guide/topics/ui/actionbar.html">Action Bar</a> developer
|
||||
guide for more information.</p>
|
||||
<p>See <a href="{@docRoot}training/appbar/action-views.html">Action
|
||||
Views and Action Providers</a> for more information.</p>
|
||||
<p class="warning"><strong>Warning:</strong> If you obfuscate your code using <a
|
||||
href="{@docRoot}tools/help/proguard.html">ProGuard</a> (or a similar tool),
|
||||
be sure to exclude the class you specify in this attribute from renaming, because it can break the
|
||||
@@ -168,8 +168,8 @@ functionality.</p>
|
||||
<dd><em>Class name</em>. A fully-qualified class name for the {@link
|
||||
android.view.ActionProvider} to use in place of the action item. For example,
|
||||
{@code "android.widget.ShareActionProvider"} to use {@link android.widget.ShareActionProvider}.
|
||||
<p>See the <a href="{@docRoot}guide/topics/ui/actionbar.html">Action Bar</a> developer
|
||||
guide for more information.</p>
|
||||
<p>See <a href="{@docRoot}training/appbar/action-views.html">Action
|
||||
Views and Action Providers</a> for more information.</p>
|
||||
<p class="warning"><strong>Warning:</strong> If you obfuscate your code using <a
|
||||
href="{@docRoot}tools/help/proguard.html">ProGuard</a> (or a similar tool),
|
||||
be sure to exclude the class you specify in this attribute from renaming, because it can break the
|
||||
|
||||
@@ -134,8 +134,7 @@ data, and displays the search results.</p></li>
|
||||
<li>Or, a {@link android.widget.SearchView} widget
|
||||
<p>Using the search widget allows you to put the search box anywhere in your activity.
|
||||
Instead of putting it in your activity layout, you should usually use
|
||||
{@link android.widget.SearchView} as an
|
||||
<a href="{@docRoot}guide/topics/ui/actionbar.html#ActionView">action view in the Action Bar</a>.</p>
|
||||
{@link android.widget.SearchView} as an action view in the app bar.</p>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
@@ -493,10 +492,10 @@ the Android system and other apps, you should label your button with the Android
|
||||
available from the <a href="{@docRoot}design/downloads/index.html#action-bar-icon-pack">Action Bar
|
||||
Icon Pack</a>.</p>
|
||||
|
||||
<p class="note"><strong>Note:</strong> If your app uses the <a
|
||||
href="{@docRoot}guide/topics/ui/actionbar.html">action bar</a>, then you should not use
|
||||
<p class="note"><strong>Note:</strong> If your app uses an <a
|
||||
href="{@docRoot}training/appbar/index.html">app bar</a>, then you should not use
|
||||
the search dialog for your search interface. Instead, use the <a href="#UsingSearchWidget">search
|
||||
widget</a> as a collapsible view in the action bar.</p>
|
||||
widget</a> as a collapsible view in the app bar.</p>
|
||||
|
||||
<p>You can also enable "type-to-search" functionality, which activates the search dialog when the
|
||||
user starts typing on the keyboard—the keystrokes are inserted into the search dialog. You can
|
||||
@@ -680,10 +679,9 @@ android.widget.SearchView} widget as an "action view" in the Action Bar.</p>
|
||||
|
||||
<p>The {@link android.widget.SearchView} widget is available in Android 3.0 and higher. If
|
||||
you're developing your application for Android 3.0 and have decided to use the search widget, we
|
||||
recommend that you insert the search widget as an <a
|
||||
href="{@docRoot}guide/topics/ui/actionbar.html#ActionView">action view in the Action Bar</a>,
|
||||
recommend that you insert the search widget as an action view in the app bar,
|
||||
instead of using the search dialog (and instead of placing the search widget in your activity
|
||||
layout). For example, figure 2 shows the search widget in the Action Bar.</p>
|
||||
layout). For example, figure 2 shows the search widget in the app bar.</p>
|
||||
|
||||
<p>The search widget provides the same functionality as the search dialog. It starts the appropriate
|
||||
activity when the user executes a search, and it can provide search suggestions and perform voice
|
||||
@@ -707,8 +705,8 @@ android.app.SearchableInfo} object that represents your searchable configuration
|
||||
android.app.SearchManager#getSearchableInfo getSearchableInfo()} on {@link
|
||||
android.app.SearchManager}.</p>
|
||||
|
||||
<p>For example, if you're using a {@link android.widget.SearchView} as an action view in the <a
|
||||
href="{@docRoot}guide/topics/ui/actionbar.html">Action Bar</a>, you should enable the widget
|
||||
<p>For example, if you're using a {@link android.widget.SearchView} as an action view in the
|
||||
<a href="{@docRoot}training/appbar/index.html">app bar</a>, you should enable the widget
|
||||
during the {@link android.app.Activity#onCreateOptionsMenu onCreateOptionsMenu()} callback:</p>
|
||||
|
||||
<pre>
|
||||
@@ -738,9 +736,8 @@ with some callback methods and event listeners. For more information, see the re
|
||||
documentation for {@link android.widget.SearchView} and its nested interfaces for the
|
||||
appropriate event listeners.</p>
|
||||
|
||||
<p>For more information about action views in the Action Bar, read the <a
|
||||
href="{@docRoot}guide/topics/ui/actionbar.html#ActionView">Action Bar</a> developer guide (which
|
||||
includes sample code for adding a search widget as an action view).</p>
|
||||
<p>For more information about action views in the Action Bar, see
|
||||
<a href="{@docRoot}training/appbar/action-views.html">Action Views and Action Providers</a>.</p>
|
||||
|
||||
|
||||
<h3 id="WidgetFeatures">Other search widget features</h3>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -47,7 +47,7 @@ parent.link=index.html
|
||||
|
||||
<h2>See also</h2>
|
||||
<ol>
|
||||
<li><a href="{@docRoot}guide/topics/ui/actionbar.html">Action Bar</a></li>
|
||||
<li><a href="{@docRoot}training/appbar/index.html">Adding the App Bar</a></li>
|
||||
<li><a href="{@docRoot}guide/topics/resources/menu-resource.html">Menu Resource</a></li>
|
||||
<li><a
|
||||
href="http://android-developers.blogspot.com/2012/01/say-goodbye-to-menu-button.html">Say
|
||||
@@ -62,7 +62,7 @@ actions and other options in your activities.</p>
|
||||
|
||||
<p>Beginning with Android 3.0 (API level 11), Android-powered devices are no longer required to
|
||||
provide a dedicated <em>Menu</em> button. With this change, Android apps should migrate away from a
|
||||
dependence on the traditional 6-item menu panel and instead provide an action bar to present common
|
||||
dependence on the traditional 6-item menu panel and instead provide an app bar to present common
|
||||
user actions.</p>
|
||||
|
||||
<p>Although the design and user experience for some menu items have changed, the semantics to define
|
||||
@@ -71,14 +71,14 @@ guide shows how to create the three fundamental types of menus or action present
|
||||
versions of Android:</p>
|
||||
|
||||
<dl>
|
||||
<dt><strong>Options menu and action bar</strong></dt>
|
||||
<dt><strong>Options menu and app bar</strong></dt>
|
||||
<dd>The <a href="#options-menu">options menu</a> is the primary collection of menu items for an
|
||||
activity. It's where you should place actions that have a global impact on the app, such as
|
||||
"Search," "Compose email," and "Settings."
|
||||
<p>If you're developing for Android 2.3 or lower, users can
|
||||
reveal the options menu panel by pressing the <em>Menu</em> button.</p>
|
||||
<p>On Android 3.0 and higher, items from the options menu are presented by the <a
|
||||
href="{@docRoot}guide/topics/ui/actionbar.html">action bar</a> as a combination of on-screen action
|
||||
<p>On Android 3.0 and higher, items from the options menu are presented by the
|
||||
app bar as a combination of on-screen action
|
||||
items and overflow options. Beginning with Android 3.0, the <em>Menu</em> button is deprecated (some
|
||||
devices
|
||||
don't have one), so you should migrate toward using the action bar to provide access to actions and
|
||||
@@ -173,8 +173,8 @@ when the user selects it.</dd>
|
||||
<dt>{@code android:title}</dt>
|
||||
<dd>A reference to a string to use as the item's title.</dd>
|
||||
<dt>{@code android:showAsAction}</dt>
|
||||
<dd>Specifies when and how this item should appear as an action item in the <a
|
||||
href="{@docRoot}guide/topics/ui/actionbar.html">action bar</a>.</dd>
|
||||
<dd>Specifies when and how this item should appear as an action item in the
|
||||
app bar.</dd>
|
||||
</dl>
|
||||
|
||||
<p>These are the most important attributes you should use, but there are many more available.
|
||||
@@ -233,25 +233,20 @@ the sixth item and the rest into the overflow menu, which the user can open by s
|
||||
<em>More</em>.</li>
|
||||
|
||||
<li>If you've developed your application for <strong>Android 3.0 (API level 11) and
|
||||
higher</strong>, items from the options menu are available in the <a
|
||||
href="{@docRoot}guide/topics/ui/actionbar.html">action bar</a>. By default, the system
|
||||
higher</strong>, items from the options menu are available in the
|
||||
app bar. By default, the system
|
||||
places all items in the action overflow, which the user can reveal with the action overflow icon on
|
||||
the right side of the action bar (or by pressing the device <em>Menu</em> button, if available). To
|
||||
the right side of the app bar (or by pressing the device <em>Menu</em> button, if available). To
|
||||
enable
|
||||
quick access to important actions, you can promote a few items to appear in the action bar by adding
|
||||
quick access to important actions, you can promote a few items to appear in the app bar by adding
|
||||
{@code android:showAsAction="ifRoom"} to the corresponding {@code <item>} elements (see figure
|
||||
2). <p>For more information about action items and other action bar behaviors, see the <a
|
||||
href="{@docRoot}guide/topics/ui/actionbar.html">Action Bar</a> guide. </p>
|
||||
<p class="note"><strong>Note:</strong> Even if you're <em>not</em> developing for Android 3.0 or
|
||||
higher, you can build your own action bar layout for a similar effect. For an example of how you can
|
||||
support older versions of Android with an action bar, see the <a
|
||||
href="{@docRoot}resources/samples/ActionBarCompat/index.html">Action Bar Compatibility</a>
|
||||
sample.</p>
|
||||
2). <p>For more information about action items and other app bar behaviors, see the <a
|
||||
href="{@docRoot}training/appbar/index.html">Adding the App Bar</a> training class. </p>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<img src="{@docRoot}images/ui/actionbar.png" alt="" />
|
||||
<p class="img-caption"><strong>Figure 2.</strong> Action bar from the <a
|
||||
<p class="img-caption"><strong>Figure 2.</strong> App bar from the <a
|
||||
href="{@docRoot}resources/samples/HoneycombGallery/index.html">Honeycomb Gallery</a> app, showing
|
||||
navigation tabs and a camera action item (plus the action overflow button).</p>
|
||||
|
||||
@@ -285,13 +280,13 @@ properties with {@link android.view.MenuItem} APIs.</p>
|
||||
android.app.Activity#onCreateOptionsMenu(Menu) onCreateOptionsMenu()} to create the options menu
|
||||
when the user opens the menu for the first time. If you've developed for Android 3.0 and higher, the
|
||||
system calls {@link android.app.Activity#onCreateOptionsMenu(Menu) onCreateOptionsMenu()} when
|
||||
starting the activity, in order to show items to the action bar.</p>
|
||||
starting the activity, in order to show items to the app bar.</p>
|
||||
|
||||
|
||||
|
||||
<h3 id="RespondingOptionsMenu">Handling click events</h3>
|
||||
|
||||
<p>When the user selects an item from the options menu (including action items in the action bar),
|
||||
<p>When the user selects an item from the options menu (including action items in the app bar),
|
||||
the system calls your activity's {@link android.app.Activity#onOptionsItemSelected(MenuItem)
|
||||
onOptionsItemSelected()} method. This method passes the {@link android.view.MenuItem} selected. You
|
||||
can identify the item by calling {@link android.view.MenuItem#getItemId()}, which returns the unique
|
||||
@@ -370,7 +365,7 @@ onPrepareOptionsMenu()} each time the user opens the options menu (presses the <
|
||||
button).</p>
|
||||
|
||||
<p>On Android 3.0 and higher, the options menu is considered to always be open when menu items are
|
||||
presented in the action bar. When an event occurs and you want to perform a menu update, you must
|
||||
presented in the app bar. When an event occurs and you want to perform a menu update, you must
|
||||
call {@link android.app.Activity#invalidateOptionsMenu invalidateOptionsMenu()} to request that the
|
||||
system call {@link android.app.Activity#onPrepareOptionsMenu(Menu) onPrepareOptionsMenu()}.</p>
|
||||
|
||||
@@ -505,8 +500,8 @@ and the contextual action bar disappears when the user deselects all items, pres
|
||||
or selects the <em>Done</em> action on the left side of the bar.</p>
|
||||
|
||||
<p class="note"><strong>Note:</strong> The contextual action bar is not necessarily
|
||||
associated with the <a href="{@docRoot}guide/topics/ui/actionbar.html">action bar</a>. They operate
|
||||
independently, even though the contextual action bar visually overtakes the action bar
|
||||
associated with the app bar. They operate
|
||||
independently, even though the contextual action bar visually overtakes the app bar
|
||||
position.</p>
|
||||
|
||||
<p>If you're developing for Android 3.0 (API level 11) or higher, you
|
||||
|
||||
@@ -67,7 +67,7 @@ Layouts</a>.
|
||||
android.view.ViewGroup} objects. Android provides several app components that offer
|
||||
a standard UI layout for which you simply need to define the content. These UI components each
|
||||
have a unique set of APIs that are described in their respective documents, such as <a
|
||||
href="{@docRoot}guide/topics/ui/actionbar.html">Action Bar</a>, <a
|
||||
href="{@docRoot}training/appbar/index.html">Adding the App Bar</a>, <a
|
||||
href="{@docRoot}guide/topics/ui/dialogs.html">Dialogs</a>, and <a
|
||||
href="{@docRoot}guide/topics/ui/notifiers/notifications.html">Status Notifications</a>.</p>
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ next.link=search.html
|
||||
<h2>This lesson teaches you to</h2>
|
||||
|
||||
<ul>
|
||||
<li><a href="{@docRoot}training/search/setup.html#add-sv">Add the Search View to the Action
|
||||
<li><a href="{@docRoot}training/search/setup.html#add-sv">Add the Search View to the App
|
||||
Bar</a></li>
|
||||
|
||||
<li><a href="{@docRoot}training/search/setup.html#create-sc">Create a Searchable
|
||||
@@ -23,30 +23,30 @@ next.link=search.html
|
||||
<h2>You should also read:</h2>
|
||||
|
||||
<ul>
|
||||
<li><a href="{@docRoot}guide/topics/ui/actionbar.html">Action Bar</a></li>
|
||||
<li><a href="{@docRoot}training/appbar/index.html">Adding the App Bar</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p>Beginning in Android 3.0, using the {@link android.widget.SearchView} widget as an item in
|
||||
the action bar is the preferred way to provide search in your app. Like with all items in
|
||||
the action bar, you can define the {@link android.widget.SearchView} to show at all times, only
|
||||
the app bar is the preferred way to provide search in your app. Like with all items in
|
||||
the app bar, you can define the {@link android.widget.SearchView} to show at all times, only
|
||||
when there is room, or as a collapsible action, which displays the {@link
|
||||
android.widget.SearchView} as an icon initially, then takes up the entire action bar as a search
|
||||
android.widget.SearchView} as an icon initially, then takes up the entire app bar as a search
|
||||
field when the user clicks the icon.</p>
|
||||
|
||||
<p class="note"><strong>Note:</strong> Later in this class, you will learn how to make your
|
||||
app compatible down to Android 2.1 (API level 7) for devices that do not support
|
||||
{@link android.widget.SearchView}.</p>
|
||||
|
||||
<h2 id="add-sv">Add the Search View to the Action Bar</h2>
|
||||
<h2 id="add-sv">Add the Search View to the App Bar</h2>
|
||||
|
||||
<p>To add a {@link android.widget.SearchView} widget to the action bar, create a file named
|
||||
<p>To add a {@link android.widget.SearchView} widget to the app bar, create a file named
|
||||
<code>res/menu/options_menu.xml</code> in your project and add the following code to the file.
|
||||
This code defines how to create the search item, such as the icon to use and the title of the
|
||||
item. The <code>collapseActionView</code> attribute allows your {@link android.widget.SearchView}
|
||||
to expand to take up the whole action bar and collapse back down into a
|
||||
normal action bar item when not in use. Because of the limited action bar space on handset devices,
|
||||
to expand to take up the whole app bar and collapse back down into a
|
||||
normal app bar item when not in use. Because of the limited app bar space on handset devices,
|
||||
using the <code>collapsibleActionView</code> attribute is recommended to provide a better
|
||||
user experience.</p>
|
||||
<pre>
|
||||
@@ -63,7 +63,7 @@ next.link=search.html
|
||||
<p class="note"><strong>Note:</strong> If you already have an existing XML file for your menu
|
||||
items, you can add the <code><item></code> element to that file instead.</p>
|
||||
|
||||
<p>To display the {@link android.widget.SearchView} in the action bar, inflate the XML menu
|
||||
<p>To display the {@link android.widget.SearchView} in the app bar, inflate the XML menu
|
||||
resource (<code>res/menu/options_menu.xml</code>) in the {@link
|
||||
android.app.Activity#onCreateOptionsMenu onCreateOptionsMenu()} method of your activity:</p>
|
||||
<pre>
|
||||
@@ -76,7 +76,7 @@ public boolean onCreateOptionsMenu(Menu menu) {
|
||||
}
|
||||
</pre>
|
||||
|
||||
<p>If you run your app now, the {@link android.widget.SearchView} appears in your app's action
|
||||
<p>If you run your app now, the {@link android.widget.SearchView} appears in your app's app
|
||||
bar, but it isn't functional. You now need to define <em>how</em> the {@link
|
||||
android.widget.SearchView} behaves.</p>
|
||||
|
||||
@@ -194,4 +194,4 @@ public class SearchResultsActivity extends Activity {
|
||||
|
||||
<p>If you run your app now, the {@link android.widget.SearchView} can accept the user's query and
|
||||
start your searchable activity with the {@link android.content.Intent#ACTION_SEARCH} intent. It
|
||||
is now up to you to figure out how to store and search your data given a query.</p>
|
||||
is now up to you to figure out how to store and search your data given a query.</p>
|
||||
|
||||
@@ -21,7 +21,8 @@ previous.link=receive.html
|
||||
<!-- other docs (NOT javadocs) -->
|
||||
<h2>You should also read</h2>
|
||||
<ul>
|
||||
<li><a href="{@docRoot}guide/topics/ui/actionbar.html">Action Bar</a></li>
|
||||
<li><a href="{@docRoot}training/appbar/action-views.html">Action Views and
|
||||
Action Providers</a></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
@@ -121,7 +122,8 @@ private void setShareIntent(Intent shareIntent) {
|
||||
want to set it and then update it as the UI changes. For example, when you view photos full screen
|
||||
in the Gallery app, the sharing intent changes as you flip between photos.</p>
|
||||
|
||||
<p>For further discussion about the {@link android.widget.ShareActionProvider} object, see the <a
|
||||
href="{@docRoot}guide/topics/ui/actionbar.html#ActionProvider">Action Bar</a> guide.</p>
|
||||
<p>For further discussion about the {@link android.widget.ShareActionProvider}
|
||||
object, see <a href="{@docRoot}training/appbar/action-views.html">Action Views
|
||||
and Action Providers</a>.</p>
|
||||
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ trainingnavtop=true
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<a href="{@docRoot}guide/topics/ui/actionbar.html">Action Bar</a> API Guide
|
||||
<a href="{@docRoot}training/appbar/index.html">Adding the App Bar</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{@docRoot}design/index.html">
|
||||
|
||||
@@ -21,7 +21,7 @@ trainingnavtop=true
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<a href="{@docRoot}guide/topics/ui/actionbar.html">Action Bar</a> API Guide
|
||||
<a href="{@docRoot}training/appbar/index.html">Adding the App Bar</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{@docRoot}design/patterns/fullscreen.html">
|
||||
|
||||
@@ -24,7 +24,7 @@ startpage=true
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<a href="{@docRoot}guide/topics/ui/actionbar.html">Action Bar</a> API Guide
|
||||
<a href="{@docRoot}training/appbar/index.html">Adding the App Bar</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{@docRoot}design/patterns/fullscreen.html">
|
||||
|
||||
@@ -20,7 +20,7 @@ trainingnavtop=true
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<a href="{@docRoot}guide/topics/ui/actionbar.html">Action Bar</a> API Guide
|
||||
<a href="{@docRoot}training/appbar/index.html">Adding the App Bar</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{@docRoot}design/index.html">
|
||||
|
||||
@@ -23,7 +23,7 @@ trainingnavtop=true
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<a href="{@docRoot}guide/topics/ui/actionbar.html">Action Bar</a> API Guide
|
||||
<a href="{@docRoot}training/appbar/index.html">Adding the App Bar</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{@docRoot}design/index.html">
|
||||
@@ -198,7 +198,7 @@ insets (and hence your app's layout) however you want. </p>
|
||||
<h2 id="action-bar">Synchronize the Status Bar with Action Bar Transition</h2>
|
||||
|
||||
<p>On Android 4.1 and higher, to avoid resizing your layout when the action bar hides and
|
||||
shows, you can enable overlay mode for the <a href="{@docRoot}guide/topics/ui/actionbar.html">action bar</a>.
|
||||
shows, you can enable overlay mode for the action bar.
|
||||
When in overlay mode, your activity layout uses all the
|
||||
space available as if the action bar is not there and the system draws the action bar in
|
||||
front of your layout. This obscures some of the layout at the top, but now when the
|
||||
|
||||
@@ -19,7 +19,7 @@ trainingnavtop=true
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<a href="{@docRoot}guide/topics/ui/actionbar.html">Action Bar</a> API Guide
|
||||
<a href="{@docRoot}training/appbar/index.html">Adding the App Bar</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{@docRoot}design/index.html">
|
||||
|
||||
Reference in New Issue
Block a user