xref: /aosp_15_r20/developers/build/prebuilts/gradle/ActionBarCompat-Basic/README.md (revision d353a188ca6ec4b5eba25b5fbd7bcb8ce61322fb)
1*d353a188SXin Li
2*d353a188SXin LiAndroid ActionBarCompat-Basic Sample
3*d353a188SXin Li===================================
4*d353a188SXin Li
5*d353a188SXin LiThis sample shows you how to use ActionBarCompat to create a basic Activity
6*d353a188SXin Liwhich displays action items. It covers inflating items from a menu resource,
7*d353a188SXin Lias well as adding an item in code.
8*d353a188SXin Li
9*d353a188SXin LiIntroduction
10*d353a188SXin Li------------
11*d353a188SXin Li
12*d353a188SXin LiAndroid 3.0 introduced the “action bar” control, a toolbar that is expected
13*d353a188SXin Lito be present in most types of applications. This control identifies the user
14*d353a188SXin Lilocation, and provides user actions and navigation modes.
15*d353a188SXin LiUsing the action bar offers your users a familiar interface across applications
16*d353a188SXin Lithat the system gracefully adapts for different screen configurations.
17*d353a188SXin Li
18*d353a188SXin LiInstantiating an action bar can be done by using the [ActionBar][1] API provided
19*d353a188SXin Liin API 11 or above. Support for older devices is provided by the
20*d353a188SXin Li[support library’s ActionBar][2] implementation, compatible back to API 7.
21*d353a188SXin LiThis sample demonstrates using the support library APIs.
22*d353a188SXin Li
23*d353a188SXin LiUsing an ActionBar with the support library requires the following steps:
24*d353a188SXin Li
25*d353a188SXin Li1. Create your activity by extending AppCompatActivity.
26*d353a188SXin Li2. Use (or extend) one of the Theme.AppCompat themes for your activity.
27*d353a188SXin Li
28*d353a188SXin LiOnce this is done, action items will be created for any options menu items that
29*d353a188SXin Liwould otherwise be created during when `[onCreateOptionsMenu()][3]` is called.
30*d353a188SXin Li
31*d353a188SXin Li[1]: http://developer.android.com/reference/android/app/ActionBar.html
32*d353a188SXin Li[2]: http://developer.android.com/reference/android/support/v7/app/ActionBar.html
33*d353a188SXin Li[3]: http://developer.android.com/reference/android/app/Activity.html#onCreateOptionsMenu(android.view.Menu)
34*d353a188SXin Li
35*d353a188SXin LiPre-requisites
36*d353a188SXin Li--------------
37*d353a188SXin Li
38*d353a188SXin Li- Android SDK 27
39*d353a188SXin Li- Android Build Tools v27.0.2
40*d353a188SXin Li- Android Support Repository
41*d353a188SXin Li
42*d353a188SXin LiScreenshots
43*d353a188SXin Li-------------
44*d353a188SXin Li
45*d353a188SXin Li<img src="screenshots/screenshot1.png" height="400" alt="Screenshot"/> <img src="screenshots/screenshot2.png" height="400" alt="Screenshot"/>
46*d353a188SXin Li
47*d353a188SXin LiGetting Started
48*d353a188SXin Li---------------
49*d353a188SXin Li
50*d353a188SXin LiThis sample uses the Gradle build system. To build this project, use the
51*d353a188SXin Li"gradlew build" command or use "Import Project" in Android Studio.
52*d353a188SXin Li
53*d353a188SXin LiSupport
54*d353a188SXin Li-------
55*d353a188SXin Li
56*d353a188SXin Li- Google+ Community: https://plus.google.com/communities/105153134372062985968
57*d353a188SXin Li- Stack Overflow: http://stackoverflow.com/questions/tagged/android
58*d353a188SXin Li
59*d353a188SXin LiIf you've found an error in this sample, please file an issue:
60*d353a188SXin Lihttps://github.com/googlesamples/android-ActionBarCompat-Basic
61*d353a188SXin Li
62*d353a188SXin LiPatches are encouraged, and may be submitted by forking this project and
63*d353a188SXin Lisubmitting a pull request through GitHub. Please see CONTRIBUTING.md for more details.
64*d353a188SXin Li
65*d353a188SXin LiLicense
66*d353a188SXin Li-------
67*d353a188SXin Li
68*d353a188SXin LiCopyright 2017 The Android Open Source Project, Inc.
69*d353a188SXin Li
70*d353a188SXin LiLicensed to the Apache Software Foundation (ASF) under one or more contributor
71*d353a188SXin Lilicense agreements.  See the NOTICE file distributed with this work for
72*d353a188SXin Liadditional information regarding copyright ownership.  The ASF licenses this
73*d353a188SXin Lifile to you under the Apache License, Version 2.0 (the "License"); you may not
74*d353a188SXin Liuse this file except in compliance with the License.  You may obtain a copy of
75*d353a188SXin Lithe License at
76*d353a188SXin Li
77*d353a188SXin Lihttp://www.apache.org/licenses/LICENSE-2.0
78*d353a188SXin Li
79*d353a188SXin LiUnless required by applicable law or agreed to in writing, software
80*d353a188SXin Lidistributed under the License is distributed on an "AS IS" BASIS, WITHOUT
81*d353a188SXin LiWARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
82*d353a188SXin LiLicense for the specific language governing permissions and limitations under
83*d353a188SXin Lithe License.
84