README.md
1 Android CustomChoiceList Sample
2 ===================================
3
4 This sample demonstrates how to create custom checkable layouts, for use with ListView's choiceMode
5 attribute.
6
7 Introduction
8 ------------
9
10 This sample demonstrates how to create custom single- or multi-choice [ListView][1] UIs on Android.
11
12 When a ListView has a `android:choiceMode` attribute set, it will allow users to "choose" one or more items. For
13 exmaple, refer to `res/layout/sample_main.xml` in this project:
14
15 ```xml
16 <ListView android:id="@android:id/list"
17 android:layout_width="match_parent"
18 android:layout_height="0dp"
19 android:layout_weight="1"
20 android:paddingLeft="@dimen/page_margin"
21 android:paddingRight="@dimen/page_margin"
22 android:scrollbarStyle="outsideOverlay"
23 android:choiceMode="multipleChoice" />
24 ```
25
26 The framework provides these default list item layouts that show standard radio buttons or check boxes next to a single
27 line of text:
28
29 - android.R.layout.simple_list_item_single_choice
30 - android.R.layout.simple_list_item_multiple_choice.
31
32 In some cases, you may want to customize this layout. When doing so, the root view must implement the Checkable
33 interface. For an example, see this sample's `CheckableLinearLayout` class.
34
35 Lastly, remember to use padding on your ListViews to adhere to the standard metrics described in the Android Design
36 guidelines. When doing so, you should set the `android:scrollbarStyle` attribute such that the scrollbar doesn't inset.
37
38 [1]: http://developer.android.com/reference/android/widget/ListView.html
39
40 Pre-requisites
41 --------------
42
43 - Android SDK v21
44 - Android Build Tools v21.1.1
45 - Android Support Repository
46
47 Screenshots
48 -------------
49
50 <img src="screenshots/1-main.png" height="400" alt="Screenshot"/> <img src="screenshots/2-settings.png" height="400" alt="Screenshot"/>
51
52 Getting Started
53 ---------------
54
55 This sample uses the Gradle build system. To build this project, use the
56 "gradlew build" command or use "Import Project" in Android Studio.
57
58 Support
59 -------
60
61 - Google+ Community: https://plus.google.com/communities/105153134372062985968
62 - Stack Overflow: http://stackoverflow.com/questions/tagged/android
63
64 If you've found an error in this sample, please file an issue:
65 https://github.com/googlesamples/android-CustomChoiceList
66
67 Patches are encouraged, and may be submitted by forking this project and
68 submitting a pull request through GitHub. Please see CONTRIBUTING.md for more details.
69
70 License
71 -------
72
73 Copyright 2014 The Android Open Source Project, Inc.
74
75 Licensed to the Apache Software Foundation (ASF) under one or more contributor
76 license agreements. See the NOTICE file distributed with this work for
77 additional information regarding copyright ownership. The ASF licenses this
78 file to you under the Apache License, Version 2.0 (the "License"); you may not
79 use this file except in compliance with the License. You may obtain a copy of
80 the License at
81
82 http://www.apache.org/licenses/LICENSE-2.0
83
84 Unless required by applicable law or agreed to in writing, software
85 distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
86 WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
87 License for the specific language governing permissions and limitations under
88 the License.
89