README.md
1 Android DoneBar Sample
2 ===================================
3
4 This sample shows how to create a custom view in the ActionBar to show a done button, using
5 2 alternative layouts. This is well suited for simple data entry activities, where the only
6 options for the user are to cancel or confirm the data changes.
7
8 Introduction
9 ------------
10
11 API 11 introduced the [ActionBar][1] as a navigational UI element. In most cases, a custom view isn't required
12 or even recommended, as using a menu xml file is all that is needed to add action icons to it. However, it is
13 possible to use a custom view and it is useful in some cases.
14
15 This sample contains two activities with custom views in their action bar, each with a "done" button. These are
16 designed to be used with simple data entry screen where the only options for the user are to cancel or confirm
17 the changes.
18
19 1. Create a layout for the [ActionBar][2].
20 2. In the activity, before setting the content view, inflate the view using the LayoutInflater.
21 3. Use `getActionBar()` to get the ActionBar, and set the display options with `ActionBar.DISPLAY_SHOW_CUSTOM`.
22 4. Set the custom view by calling `setCustomView(customActionBarView, new ActionBar.LayoutParams(
23 ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.MATCH_PARENT))` on the ActionBar.
24 5. You can now set the content view of the Activity.
25
26
27 [1]: http://developer.android.com/design/patterns/actionbar.html
28 [2]: http://developer.android.com/reference/android/app/ActionBar.html
29
30 Pre-requisites
31 --------------
32
33 - Android SDK v21
34 - Android Build Tools v21.1.1
35 - Android Support Repository
36
37 Screenshots
38 -------------
39
40 <img src="screenshots/1-main.png" height="400" alt="Screenshot"/> <img src="screenshots/2-done-bar.png" height="400" alt="Screenshot"/> <img src="screenshots/3-done-button.png" height="400" alt="Screenshot"/>
41
42 Getting Started
43 ---------------
44
45 This sample uses the Gradle build system. To build this project, use the
46 "gradlew build" command or use "Import Project" in Android Studio.
47
48 Support
49 -------
50
51 - Google+ Community: https://plus.google.com/communities/105153134372062985968
52 - Stack Overflow: http://stackoverflow.com/questions/tagged/android
53
54 If you've found an error in this sample, please file an issue:
55 https://github.com/googlesamples/android-DoneBar
56
57 Patches are encouraged, and may be submitted by forking this project and
58 submitting a pull request through GitHub. Please see CONTRIBUTING.md for more details.
59
60 License
61 -------
62
63 Copyright 2014 The Android Open Source Project, Inc.
64
65 Licensed to the Apache Software Foundation (ASF) under one or more contributor
66 license agreements. See the NOTICE file distributed with this work for
67 additional information regarding copyright ownership. The ASF licenses this
68 file to you under the Apache License, Version 2.0 (the "License"); you may not
69 use this file except in compliance with the License. You may obtain a copy of
70 the License at
71
72 http://www.apache.org/licenses/LICENSE-2.0
73
74 Unless required by applicable law or agreed to in writing, software
75 distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
76 WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
77 License for the specific language governing permissions and limitations under
78 the License.
79