android-AccessibilityRecord

来源:互联网 发布:头发怎么做酱油知乎 编辑:程序博客网 时间:2024/06/06 02:51

AccessibilityRecord

public class AccessibilityRecord 
extends Object 

java.lang.Object   ↳android.view.accessibility.AccessibilityRecord
Known Direct Subclasses


Represents a record in an AccessibilityEvent and contains information about state change of its source View. When a view fires an accessibility event it requests from its parent to dispatch the constructed event. The parent may optionally append a record for itself for providing more context toAccessibilityServices. Hence, accessibility services can facilitate additional accessibility records to enhance feedback.

Once the accessibility event containing a record is dispatched the record is made immutable and calling a state mutation method generates an error.

Note: Not all properties are applicable to all accessibility event types. For detailed information please refer to AccessibilityEvent.

Developer Guides

For more information about creating and processing AccessibilityRecords, read the Accessibility developer guide.

See also:

  • AccessibilityEvent
  • AccessibilityManager
  • AccessibilityService
  • AccessibilityNodeInfo

Summary


Public methods

intgetAddedCount()

Gets the number of added characters.

CharSequencegetBeforeText()

Sets the text before a change.

CharSequencegetClassName()

Gets the class name of the source.

CharSequencegetContentDescription()

Gets the description of the source.

intgetCurrentItemIndex()

Gets the index of the source in the list of items the can be visited.

intgetFromIndex()

Gets the index of the first character of the changed sequence, or the beginning of a text selection or the index of the first visible item when scrolling.

intgetItemCount()

Gets the number of items that can be visited.

intgetMaxScrollX()

Gets the max scroll offset of the source left edge in pixels.

intgetMaxScrollY()

Gets the max scroll offset of the source top edge in pixels.

ParcelablegetParcelableData()

Gets the Parcelable data.

intgetRemovedCount()

Gets the number of removed characters.

intgetScrollX()

Gets the scroll offset of the source left edge in pixels.

intgetScrollY()

Gets the scroll offset of the source top edge in pixels.

AccessibilityNodeInfogetSource()

Gets the AccessibilityNodeInfo of the event source.

List<CharSequence>getText()

Gets the text of the event.

intgetToIndex()

Gets the index of text selection end or the index of the last visible item when scrolling.

intgetWindowId()

Gets the id of the window from which the event comes from.

booleanisChecked()

Gets if the source is checked.

booleanisEnabled()

Gets if the source is enabled.

booleanisFullScreen()

Gets if the source is taking the entire screen.

booleanisPassword()

Gets if the source is a password field.

booleanisScrollable()

Gets if the source is scrollable.

staticAccessibilityRecordobtain()

Returns a cached instance if such is available or a new one is instantiated.

staticAccessibilityRecordobtain(AccessibilityRecord record)

Returns a cached instance if such is available or a new one is instantiated.

voidrecycle()

Return an instance back to be reused.

voidsetAddedCount(int addedCount)

Sets the number of added characters.

voidsetBeforeText(CharSequence beforeText)

Sets the text before a change.

voidsetChecked(boolean isChecked)

Sets if the source is checked.

voidsetClassName(CharSequence className)

Sets the class name of the source.

voidsetContentDescription(CharSequence contentDescription)

Sets the description of the source.

voidsetCurrentItemIndex(int currentItemIndex)

Sets the index of the source in the list of items that can be visited.

voidsetEnabled(boolean isEnabled)

Sets if the source is enabled.

voidsetFromIndex(int fromIndex)

Sets the index of the first character of the changed sequence or the beginning of a text selection or the index of the first visible item when scrolling.

voidsetFullScreen(boolean isFullScreen)

Sets if the source is taking the entire screen.

voidsetItemCount(int itemCount)

Sets the number of items that can be visited.

voidsetMaxScrollX(int maxScrollX)

Sets the max scroll offset of the source left edge in pixels.

voidsetMaxScrollY(int maxScrollY)

Sets the max scroll offset of the source top edge in pixels.

voidsetParcelableData(Parcelable parcelableData)

Sets the Parcelable data of the event.

voidsetPassword(boolean isPassword)

Sets if the source is a password field.

voidsetRemovedCount(int removedCount)

Sets the number of removed characters.

voidsetScrollX(int scrollX)

Sets the scroll offset of the source left edge in pixels.

voidsetScrollY(int scrollY)

Sets the scroll offset of the source top edge in pixels.

voidsetScrollable(boolean scrollable)

Sets if the source is scrollable.

voidsetSource(View root, int virtualDescendantId)

Sets the source to be a virtual descendant of the given root.

voidsetSource(View source)

Sets the event source.

voidsetToIndex(int toIndex)

Sets the index of text selection end or the index of the last visible item when scrolling.

StringtoString()

Returns a string representation of the object.

Inherited methods

From class java.lang.Object

Public methods


getAddedCount

Added in API level 4
int getAddedCount ()

Gets the number of added characters.

ReturnsintThe number of added characters.

getBeforeText

Added in API level 4
CharSequence getBeforeText ()

Sets the text before a change.

ReturnsCharSequenceThe text before the change.

getClassName

Added in API level 4
CharSequence getClassName ()

Gets the class name of the source.

ReturnsCharSequenceThe class name.

getContentDescription

Added in API level 4
CharSequence getContentDescription ()

Gets the description of the source.

ReturnsCharSequenceThe description.

getCurrentItemIndex

Added in API level 4
int getCurrentItemIndex ()

Gets the index of the source in the list of items the can be visited.

ReturnsintThe current item index.

getFromIndex

Added in API level 4
int getFromIndex ()

Gets the index of the first character of the changed sequence, or the beginning of a text selection or the index of the first visible item when scrolling.

ReturnsintThe index of the first character or selection start or the first visible item.

getItemCount

Added in API level 4
int getItemCount ()

Gets the number of items that can be visited.

ReturnsintThe number of items.

getMaxScrollX

Added in API level 15
int getMaxScrollX ()

Gets the max scroll offset of the source left edge in pixels.

ReturnsintThe max scroll.

getMaxScrollY

Added in API level 15
int getMaxScrollY ()

Gets the max scroll offset of the source top edge in pixels.

ReturnsintThe max scroll.

getParcelableData

Added in API level 4
Parcelable getParcelableData ()

Gets the Parcelable data.

ReturnsParcelableThe parcelable data.

getRemovedCount

Added in API level 4
int getRemovedCount ()

Gets the number of removed characters.

ReturnsintThe number of removed characters.

getScrollX

Added in API level 14
int getScrollX ()

Gets the scroll offset of the source left edge in pixels.

ReturnsintThe scroll.

getScrollY

Added in API level 14
int getScrollY ()

Gets the scroll offset of the source top edge in pixels.

ReturnsintThe scroll.

getSource

Added in API level 14
AccessibilityNodeInfo getSource ()

Gets the AccessibilityNodeInfo of the event source.

Note: It is a client responsibility to recycle the received info by calling AccessibilityNodeInfo#recycle() to avoid creating of multiple instances.

ReturnsAccessibilityNodeInfoThe info of the source.

getText

Added in API level 4
List<CharSequence> getText ()

Gets the text of the event. The index in the list represents the priority of the text. Specifically, the lower the index the higher the priority.

ReturnsList<CharSequence>The text.

getToIndex

Added in API level 14
int getToIndex ()

Gets the index of text selection end or the index of the last visible item when scrolling.

ReturnsintThe index of selection end or last item index.

getWindowId

Added in API level 14
int getWindowId ()

Gets the id of the window from which the event comes from.

ReturnsintThe window id.

isChecked

Added in API level 4
boolean isChecked ()

Gets if the source is checked.

ReturnsbooleanTrue if the view is checked, false otherwise.

isEnabled

Added in API level 4
boolean isEnabled ()

Gets if the source is enabled.

ReturnsbooleanTrue if the view is enabled, false otherwise.

isFullScreen

Added in API level 4
boolean isFullScreen ()

Gets if the source is taking the entire screen.

ReturnsbooleanTrue if the source is full screen, false otherwise.

isPassword

Added in API level 4
boolean isPassword ()

Gets if the source is a password field.

ReturnsbooleanTrue if the view is a password field, false otherwise.

isScrollable

Added in API level 14
boolean isScrollable ()

Gets if the source is scrollable.

ReturnsbooleanTrue if the source is scrollable, false otherwise.

obtain

Added in API level 14
AccessibilityRecord obtain ()

Returns a cached instance if such is available or a new one is instantiated.

ReturnsAccessibilityRecordAn instance.

obtain

Added in API level 14
AccessibilityRecord obtain (AccessibilityRecord record)

Returns a cached instance if such is available or a new one is instantiated. The instance is initialized with data from the given record.

ParametersrecordAccessibilityRecordReturnsAccessibilityRecordAn instance.

recycle

Added in API level 14
void recycle ()

Return an instance back to be reused.

Note: You must not touch the object after calling this function.

ThrowsIllegalStateExceptionIf the record is already recycled.

setAddedCount

Added in API level 4
void setAddedCount (int addedCount)

Sets the number of added characters.

ParametersaddedCountint: The number of added characters.ThrowsIllegalStateExceptionIf called from an AccessibilityService.

setBeforeText

Added in API level 4
void setBeforeText (CharSequence beforeText)

Sets the text before a change.

ParametersbeforeTextCharSequence: The text before the change.ThrowsIllegalStateExceptionIf called from an AccessibilityService.

setChecked

Added in API level 4
void setChecked (boolean isChecked)

Sets if the source is checked.

ParametersisCheckedboolean: True if the view is checked, false otherwise.ThrowsIllegalStateExceptionIf called from an AccessibilityService.

setClassName

Added in API level 4
void setClassName (CharSequence className)

Sets the class name of the source.

ParametersclassNameCharSequence: The lass name.ThrowsIllegalStateExceptionIf called from an AccessibilityService.

setContentDescription

Added in API level 4
void setContentDescription (CharSequence contentDescription)

Sets the description of the source.

ParameterscontentDescriptionCharSequence: The description.ThrowsIllegalStateExceptionIf called from an AccessibilityService.

setCurrentItemIndex

Added in API level 4
void setCurrentItemIndex (int currentItemIndex)

Sets the index of the source in the list of items that can be visited.

ParameterscurrentItemIndexint: The current item index.ThrowsIllegalStateExceptionIf called from an AccessibilityService.

setEnabled

Added in API level 4
void setEnabled (boolean isEnabled)

Sets if the source is enabled.

ParametersisEnabledboolean: True if the view is enabled, false otherwise.ThrowsIllegalStateExceptionIf called from an AccessibilityService.

setFromIndex

Added in API level 4
void setFromIndex (int fromIndex)

Sets the index of the first character of the changed sequence or the beginning of a text selection or the index of the first visible item when scrolling.

ParametersfromIndexint: The index of the first character or selection start or the first visible item.ThrowsIllegalStateExceptionIf called from an AccessibilityService.

setFullScreen

Added in API level 4
void setFullScreen (boolean isFullScreen)

Sets if the source is taking the entire screen.

ParametersisFullScreenboolean: True if the source is full screen, false otherwise.ThrowsIllegalStateExceptionIf called from an AccessibilityService.

setItemCount

Added in API level 4
void setItemCount (int itemCount)

Sets the number of items that can be visited.

ParametersitemCountint: The number of items.ThrowsIllegalStateExceptionIf called from an AccessibilityService.

setMaxScrollX

Added in API level 15
void setMaxScrollX (int maxScrollX)

Sets the max scroll offset of the source left edge in pixels.

ParametersmaxScrollXint: The max scroll.

setMaxScrollY

Added in API level 15
void setMaxScrollY (int maxScrollY)

Sets the max scroll offset of the source top edge in pixels.

ParametersmaxScrollYint: The max scroll.

setParcelableData

Added in API level 4
void setParcelableData (Parcelable parcelableData)

Sets the Parcelable data of the event.

ParametersparcelableDataParcelable: The parcelable data.ThrowsIllegalStateExceptionIf called from an AccessibilityService.

setPassword

Added in API level 4
void setPassword (boolean isPassword)

Sets if the source is a password field.

ParametersisPasswordboolean: True if the view is a password field, false otherwise.ThrowsIllegalStateExceptionIf called from an AccessibilityService.

setRemovedCount

Added in API level 4
void setRemovedCount (int removedCount)

Sets the number of removed characters.

ParametersremovedCountint: The number of removed characters.ThrowsIllegalStateExceptionIf called from an AccessibilityService.

setScrollX

Added in API level 14
void setScrollX (int scrollX)

Sets the scroll offset of the source left edge in pixels.

ParametersscrollXint: The scroll.

setScrollY

Added in API level 14
void setScrollY (int scrollY)

Sets the scroll offset of the source top edge in pixels.

ParametersscrollYint: The scroll.

setScrollable

Added in API level 14
void setScrollable (boolean scrollable)

Sets if the source is scrollable.

Parametersscrollableboolean: True if the source is scrollable, false otherwise.ThrowsIllegalStateExceptionIf called from an AccessibilityService.

setSource

Added in API level 16
void setSource (View root,                 int virtualDescendantId)

Sets the source to be a virtual descendant of the given root. If virtualDescendantId equals to NO_ID the root is set as the source.

A virtual descendant is an imaginary View that is reported as a part of the view hierarchy for accessibility purposes. This enables custom views that draw complex content to report them selves as a tree of virtual views, thus conveying their logical structure.

ParametersrootView: The root of the virtual subtree.virtualDescendantIdint: The id of the virtual descendant.

setSource

Added in API level 14
void setSource (View source)

Sets the event source.

ParameterssourceView: The source.ThrowsIllegalStateExceptionIf called from an AccessibilityService.

setToIndex

Added in API level 14
void setToIndex (int toIndex)

Sets the index of text selection end or the index of the last visible item when scrolling.

ParameterstoIndexint: The index of selection end or last item index.

toString

Added in API level 14
String toString ()

Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.

The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:

 getClass().getName() + '@' + Integer.toHexString(hashCode()) 

ReturnsStringa string representation of the object.
0 0