You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
94 lines
3.8 KiB
94 lines
3.8 KiB
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!--
|
|
Copyright 2013 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.
|
|
-->
|
|
|
|
<sample>
|
|
<name>CheckableLayout</name>
|
|
<group>Accessibility</group>
|
|
<package>com.example.android.checkablelayout</package>
|
|
<minSdk>16</minSdk>
|
|
<strings>
|
|
<intro>
|
|
<![CDATA[
|
|
Sample showing how to make an accessible custom view that extends
|
|
a layout.
|
|
]]>
|
|
</intro>
|
|
</strings>
|
|
|
|
<template src="base-build" />
|
|
|
|
<metadata>
|
|
<status>PUBLISHED</status>
|
|
<categories>Accessibility</categories>
|
|
<technologies>Android</technologies>
|
|
<languages>Java</languages>
|
|
<solutions>Mobile</solutions>
|
|
<level>BEGINNER</level>
|
|
<icon>screenshots/icon-web.png</icon>
|
|
<screenshots>
|
|
<img>screenshots/discover.png</img>
|
|
<img>screenshots/checked.png</img>
|
|
</screenshots>
|
|
<api_refs>
|
|
<android>android.view.accessibility.AccessibilityNodeInfo</android>
|
|
<android>android.view.accessibility.AccessibilityEvent</android>
|
|
</api_refs>
|
|
<description>
|
|
Sample demonstrating how to make a simple custom view accessible.
|
|
Creates a simple `CheckableFrameLayout` that has the accessibility
|
|
profile of builtin that implements the `Checkable` interface (e.g.
|
|
`Checkbox`).
|
|
</description>
|
|
<intro>
|
|
This sample implements a single custom view, a
|
|
`CheckableFrameLayout`, which implements the `Checkable` interface
|
|
and maintains a checked state.
|
|
|
|
This sample uses the custom view as a container for two overlayed
|
|
`<![CDATA[<ImageView>]]>`s. The first `<![CDATA[<ImageView>]]>` is
|
|
always displayed, while the second `<![CDATA[<ImageView>]]>`'s
|
|
display status toggles with the checked state of it's parent (the
|
|
`CheckableLayout`). This second `<![CDATA[<ImageView>]]>` uses
|
|
`android:duplicateParentState` (see `activity_main.xml`) and a
|
|
drawable that is tied to `android:state_checked` (see
|
|
`drawable/ic_checkable_item.xml`). This drawable is displayed only
|
|
when the parent is in a checked state.
|
|
|
|
This sample provides a basic introduction to Android accessibility
|
|
by showing how to make a custom view behave similar to a builtin
|
|
widget like a `Checkbox`.
|
|
Developers should focus on two methods that are overridden from the
|
|
parent class:
|
|
`onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info)` and
|
|
`onInitializeAccessibilityEvent(AccessibilityEvent event)`.
|
|
|
|
The `onInitializeAccessibilityNodeInfo()` method provides
|
|
accessibility services with information about the state of this
|
|
view. We override this method to tell an accessibility service that
|
|
this view is checkable, and we set the intitial checked state of the
|
|
view.
|
|
|
|
The `onInitializeAccessibilityEvent()` method is use by the
|
|
system to obtain additional information about the state of the view
|
|
as its state changes.
|
|
|
|
With this information, an accessibility service has what it needs to
|
|
allow a user to meaningfully discover the view and know its state.
|
|
</intro>
|
|
</metadata>
|
|
</sample>
|