Home | History | Annotate | Download | only in CustomChoiceList
      1 <?xml version="1.0" encoding="UTF-8"?>
      2 <!--
      3  Copyright 2013 The Android Open Source Project
      4 
      5  Licensed under the Apache License, Version 2.0 (the "License");
      6  you may not use this file except in compliance with the License.
      7  You may obtain a copy of the License at
      8 
      9      http://www.apache.org/licenses/LICENSE-2.0
     10 
     11  Unless required by applicable law or agreed to in writing, software
     12  distributed under the License is distributed on an "AS IS" BASIS,
     13  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     14  See the License for the specific language governing permissions and
     15  limitations under the License.
     16 -->
     17 <sample>
     18     <name>CustomChoiceList</name>
     19     <group>UI</group>
     20     <package>com.example.android.customchoicelist</package>
     21 
     22     <!-- change minSdk if needed-->
     23     <minSdk>7</minSdk>
     24 
     25     <strings>
     26         <intro>
     27             <![CDATA[
     28                 This sample demonstrates how to create custom checkable layouts, for use with ListView\'s choiceMode
     29                 attribute.
     30             ]]>
     31         </intro>
     32     </strings>
     33 
     34     <template src="base"/>
     35     <common src="logger"/>
     36 
     37 
     38     <metadata>
     39         <status>PUBLISHED</status>
     40         <categories>Widgets</categories>
     41         <technologies>Android</technologies>
     42         <languages>Java</languages>
     43         <solutions>Mobile</solutions>
     44         <level>BEGINNER</level>
     45         <icon>screenshots/icon-web.png</icon>
     46         <screenshots>
     47             <img>screenshots/1-main.png</img>
     48             <img>screenshots/2-settings.png</img>
     49         </screenshots>
     50         <api_refs>
     51             <android>android.widget.Checkable</android>
     52             <android>android.widget.ListView</android>
     53         </api_refs>
     54 
     55         <description>
     56 <![CDATA[
     57 This sample demonstrates how to create custom checkable layouts, for use with ListView's choiceMode
     58 attribute.
     59 ]]>
     60         </description>
     61 
     62         <!-- Multi-paragraph introduction to sample, from an educational point-of-view.
     63         Makrdown formatting allowed. This will be used to generate a mini-article for the
     64         sample on DAC. -->
     65         <intro>
     66 <![CDATA[
     67 This sample demonstrates how to create custom single- or multi-choice [ListView][1] UIs on Android.
     68 
     69 When a ListView has a `android:choiceMode` attribute set, it will allow users to "choose" one or more items. For
     70 exmaple, refer to `res/layout/sample_main.xml` in this project:
     71 
     72 ```xml
     73 <ListView android:id="@android:id/list"
     74     android:layout_width="match_parent"
     75     android:layout_height="0dp"
     76     android:layout_weight="1"
     77     android:paddingLeft="@dimen/page_margin"
     78     android:paddingRight="@dimen/page_margin"
     79     android:scrollbarStyle="outsideOverlay"
     80     android:choiceMode="multipleChoice" />
     81 ```
     82 
     83 The framework provides these default list item layouts that show standard radio buttons or check boxes next to a single
     84 line of text:
     85 
     86 - android.R.layout.simple_list_item_single_choice
     87 - android.R.layout.simple_list_item_multiple_choice.
     88 
     89 In some cases, you may want to customize this layout. When doing so, the root view must implement the Checkable
     90 interface. For an example, see this sample's `CheckableLinearLayout` class.
     91 
     92 Lastly, remember to use padding on your ListViews to adhere to the standard metrics described in the Android Design
     93 guidelines. When doing so, you should set the `android:scrollbarStyle` attribute such that the scrollbar doesn't inset.
     94 
     95 [1]: http://developer.android.com/reference/android/widget/ListView.html
     96 ]]>
     97         </intro>
     98     </metadata>
     99 </sample>
    100