Please note that the contents of this offline web site may be out of date. To access the most recent documentation visit the online version .
Note that links that point to online resources are green in color and will open in a new window.
We would love it if you could give us feedback about this material by filling this form (You have to be online to fill it)
CustomChoiceList / res / layout /

sample_main.xml

       
        1
       
       
        <!--
       
       
        2
       
       
        Copyright 2013 The Android Open Source Project
       
       
        3
       
       
       
       
        4
       
       
        Licensed under the Apache License, Version 2.0 (the "License");
       
       
        5
       
       
        you may not use this file except in compliance with the License.
       
       
        6
       
       
        You may obtain a copy of the License at
       
       
        7
       
       
       
       
        8
       
       
        http://www.apache.org/licenses/LICENSE-2.0
       
       
        9
       
       
       
       
        10
       
       
        Unless required by applicable law or agreed to in writing, software
       
       
        11
       
       
        distributed under the License is distributed on an "AS IS" BASIS,
       
       
        12
       
       
        WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       
       
        13
       
       
        See the License for the specific language governing permissions and
       
       
        14
       
       
        limitations under the License.
       
       
        15
       
       
        -->
       
       
        16
       
       
       
       
        17
       
       
        <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
       
       
        18
       
       
        android:layout_width="match_parent"
       
       
        19
       
       
        android:layout_height="match_parent"
       
       
        20
       
       
        android:orientation="vertical"
       
       
        21
       
       
        android:showDividers="middle"
       
       
        22
       
       
        android:divider="?android:dividerHorizontal">
       
       
        23
       
       
       
       
        24
       
       
        <TextView style="@style/Widget.DescriptionBar"
       
       
        25
       
       
        android:layout_width="match_parent"
       
       
        26
       
       
        android:layout_height="wrap_content"
       
       
        27
       
       
        android:text="@string/intro_message" />
       
       
        28
       
       
       
       
        29
       
       
        <!--
       
       
        30
       
       
        When a ListView has a choiceMode set, it will allow users to "choose"
       
       
        31
       
       
        one or more items. The framework provides default list item layouts
       
       
        32
       
       
        that show standard radio buttons or check boxes next to a
       
       
        33
       
       
        single line of text:
       
       
        34
       
       
       
       
        35
       
       
        android.R.layout.simple_list_item_single_choice and
       
       
        36
       
       
        android.R.layout.simple_list_item_multiple_choice.
       
       
        37
       
       
       
       
        38
       
       
        In some cases, you may want to customize this layout. When doing so,
       
       
        39
       
       
        the root view must implement the Checkable interface.
       
       
        40
       
       
       
       
        41
       
       
        Lastly, remember to use padding on your ListViews to adhere to the standard
       
       
        42
       
       
        metrics described in the Android Design guidelines. When doing so,
       
       
        43
       
       
        you should set the android:scrollbarStyle such that the scrollbar
       
       
        44
       
       
        doesn'isn't inset.
       
       
        45
       
       
        -->
       
       
        46
       
       
        <ListView android:id="@android:id/list"
       
       
        47
       
       
        android:layout_width="match_parent"
       
       
        48
       
       
        android:layout_height="0dp"
       
       
        49
       
       
        android:layout_weight="1"
       
       
        50
       
       
        android:paddingLeft="@dimen/page_margin"
       
       
        51
       
       
        android:paddingRight="@dimen/page_margin"
       
       
        52
       
       
        android:scrollbarStyle="outsideOverlay"
       
       
        53
       
       
        android:choiceMode="multipleChoice" />
       
       
        54
       
       
        </LinearLayout>