Help Center
Local Navigation
- Understanding accessibility
- Best practice: Designing accessible applications
-
Developing accessible BlackBerry device applications by using the Accessibility API
- Accessibility API concepts
- Introduction to the Accessibility API
- The AccessibilityDemo sample application
- Notifying an assistive technology application when the UI changes
- UI changes that trigger a notification to an assistive technology application
- UI component states and properties
- Provide an assistive technology application with information about a UI change
- Provide an assistive technology application with information about text changes
- Provide an assistive technology application with access to information from a table
- Provide an assistive technology application with access to numeric values
- Enable an assistive technology application to receive notification of UI events
- Test an accessible BlackBerry device application
- Related resources
- Provide feedback
- Document revision history
- Legal notice
BlackBerry Manuals & Help
>
Developer Documentation
>
Java Development Guides and API Reference
>
Development Guide
Accessibility - BlackBerry Java SDK - 6.0
Provide an assistive technology application with information about a UI change
- Import the required interface.
import net.rim.device.api.ui.accessibility.AccessibleContext;
AccessibleContext provides the basic accessibility information about a custom UI component. - Create a class that extends the Field class and implements AccessibleContext.
public class MyCustomComponent extends Field implements AccessibleContext { } - Create the variables to store the accessibility information for a custom UI component, such as state information.
private int _state = AccessibleState.UNSET; private String _accessibleName; private String _title;
- Create the methods that add and remove the states for a custom UI component.
protected void addAccessibleStates(int states) { _state = _state & ~AccessibleState.UNSET; _state = _state | states; } protected void removeAccessibleStates(int states) { _state = _state & ~states; } public void setAccessibleName(String accessibleName) { _accessibleName = accessibleName; } - Implement the get() methods of AccessibleContext to provide access to the tabular, textual, or numerical information for a custom UI component.
Return null if the method does not apply to a custom UI component. For example, if the component does not provide textual information, return null in getAccessibleText().
public AccessibleTable getAccessibleTable() { return null; } public AccessibleText getAccessibleText() { return null; } public AccessibleValue getAccessibleValue() { return null; } - Create a method that returns an instance of the class that implements AccessibleContext to provide accessibility information about a change to a custom UI component.
public AccessibleContext getAccessibleContext() { return this; } - Implement AccessibleContext.getAccessibleRole() to provide information about the type of custom UI component.
public int getAccessibleRole() { return AccessibleRole.PANEL; } - Implement AccessibleContext.getAccessibleChildCount() to provide information about the number of accessible child components that a custom UI component contains. It is up to you as the developer of a custom UI component to decide whether or not the component contains accessible children. For example, you can decide whether a child element is an accessible child component based on whether the child element can gain focus and whether the user can interact with the child element directly.
public int getAccessibleChildCount() { return _icons.size(); } - Implement AccessibleContext.getAccessibleChildAt(int) to provide information about an accessible child component that a custom UI component contains.
public AccessibleContext getAccessibleChildAt(int arg0) { return (Icon) _icons.elementAt( index ); } - Implement AccessibleContext.getAccessibleName() to provide the name of a custom UI component that changes.
public String getAccessibleName() { return _accessibleName; } - Create a method that invokes AccessibleEventDispatcher.dispatchAccessibleEvent(stateChange, oldState, newState, this) to send a notification when the state of a custom UI component changes. Pass the following arguments to the method:
- the event
- the old state of the custom UI component
- the new state of the custom UI component
- an instance of the custom UI component
protected void onFocus(int direction) { super.onFocus(direction); int oldState = _state; _state = _state | AccessibleState.FOCUSED; if(isVisible()) { AccessibleEventDispatcher.dispatchAccessibleEvent( AccessibleContext.ACCESSIBLE_STATE_CHANGED, new Integer(oldState), new Integer(_state), this); } }
Previous topic: UI component states and properties