home | career | drupal | java | mac | mysql | perl | scala | uml | unix

Android example source code file (checkable.xml)

This example Android source code file (checkable.xml) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Android by Example" TM.

Java - Android tags/keywords

all, android, apache, carefully, conditions, copyright, is, license, notice, of, or, project, source, the

The checkable.xml Android example source code

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2008 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->

<menu xmlns:android="http://schemas.android.com/apk/res/android">

    <!-- Checkable items appear only in submenus or context menus. -->

    <!-- Carefully look at the attribute name checkableBehavior on groups, but
         the attribute name checkable on items. The checkableBehavior encompasses
         the number of items that will be checkable within that group. -->

    <item android:title="None">
        <menu>
            <!-- The none checkableBehavior is default, but we explicitly show it here. -->
            <group android:id="@+id/noncheckable_group"
                    android:checkableBehavior="none">
                <!-- Notice how these items inherit from the group. -->
                <item android:id="@+id/noncheckable_item_1"
                        android:title="@string/item_1" />
                <item android:id="@+id/noncheckable_item_2"
                        android:title="@string/item_2" />
                <item android:id="@+id/noncheckable_item_3"
                        android:title="@string/item_3" />
            </group>
        </menu>
    </item>

    <item android:title="All">
        <menu>
            <group android:id="@+id/checkable_group"
                    android:checkableBehavior="all">
                <!-- Notice how these items inherit from the group. -->
                <item android:id="@+id/checkable_item_1"
                        android:title="@string/item_1" />
                <item android:id="@+id/checkable_item_2"
                        android:title="@string/item_2"
                        android:checked="true" />
                <item android:id="@+id/checkable_item_3"
                        android:title="@string/item_3"
                        android:checked="true" />
            </group>
        </menu>
    </item>

    <item android:title="Single">
        <menu>
            <group android:id="@+id/exclusive_checkable_group"
                    android:checkableBehavior="single">
                <!-- Notice how these items inherit from the group. -->
                <item android:id="@+id/exclusive_checkable_item_1"
                        android:title="@string/item_1" />
                <item android:id="@+id/exclusive_checkable_item_2"
                        android:title="@string/item_2" />
                <item android:id="@+id/exclusive_checkable_item_3"
                        android:title="@string/item_3"
                        android:checked="true" />
            </group>
        </menu>
    </item>

    <item android:title="All without group">
        <menu>
            <!-- Notice how these items have each set. -->
            <item android:id="@+id/nongroup_checkable_item_1"
                    android:title="@string/item_1"
                    android:checkable="true" />
            <item android:id="@+id/nongroup_checkable_item_2"
                    android:title="@string/item_2"
                    android:checkable="true"
                    android:checked="true" />
            <item android:id="@+id/nongroup_checkable_item_3"
                    android:title="@string/item_3"
                    android:checkable="true"
                    android:checked="true" />
        </menu>
    </item>

</menu>

Other Android examples (source code examples)

Here is a short list of links related to this Android checkable.xml source code file:

new blog posts

 

Copyright 1998-2013 Alvin Alexander, alvinalexander.com
All Rights Reserved.