android-AccessibilityRecord
来源:互联网 发布:头发怎么做酱油知乎 编辑:程序博客网 时间:2024/06/06 02:51
AccessibilityRecord
public class AccessibilityRecord
extends Object
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 toAccessibilityService
s. 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
int
getAddedCount()
Gets the number of added characters.
CharSequence
getBeforeText()
Sets the text before a change.
CharSequence
getClassName()
Gets the class name of the source.
CharSequence
getContentDescription()
Gets the description of the source.
int
getCurrentItemIndex()
Gets the index of the source in the list of items the can be visited.
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.
int
getItemCount()
Gets the number of items that can be visited.
int
getMaxScrollX()
Gets the max scroll offset of the source left edge in pixels.
int
getMaxScrollY()
Gets the max scroll offset of the source top edge in pixels.
Parcelable
getParcelableData()
Gets the Parcelable
data.
int
getRemovedCount()
Gets the number of removed characters.
int
getScrollX()
Gets the scroll offset of the source left edge in pixels.
int
getScrollY()
Gets the scroll offset of the source top edge in pixels.
AccessibilityNodeInfo
getSource()
Gets the AccessibilityNodeInfo
of the event source.
List<CharSequence>
getText()
Gets the text of the event.
int
getToIndex()
Gets the index of text selection end or the index of the last visible item when scrolling.
int
getWindowId()
Gets the id of the window from which the event comes from.
boolean
isChecked()
Gets if the source is checked.
boolean
isEnabled()
Gets if the source is enabled.
boolean
isFullScreen()
Gets if the source is taking the entire screen.
boolean
isPassword()
Gets if the source is a password field.
boolean
isScrollable()
Gets if the source is scrollable.
staticAccessibilityRecord
obtain()
Returns a cached instance if such is available or a new one is instantiated.
staticAccessibilityRecord
obtain(AccessibilityRecord record)
Returns a cached instance if such is available or a new one is instantiated.
void
recycle()
Return an instance back to be reused.
void
setAddedCount(int addedCount)
Sets the number of added characters.
void
setBeforeText(CharSequence beforeText)
Sets the text before a change.
void
setChecked(boolean isChecked)
Sets if the source is checked.
void
setClassName(CharSequence className)
Sets the class name of the source.
void
setContentDescription(CharSequence contentDescription)
Sets the description of the source.
void
setCurrentItemIndex(int currentItemIndex)
Sets the index of the source in the list of items that can be visited.
void
setEnabled(boolean isEnabled)
Sets if the source is enabled.
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.
void
setFullScreen(boolean isFullScreen)
Sets if the source is taking the entire screen.
void
setItemCount(int itemCount)
Sets the number of items that can be visited.
void
setMaxScrollX(int maxScrollX)
Sets the max scroll offset of the source left edge in pixels.
void
setMaxScrollY(int maxScrollY)
Sets the max scroll offset of the source top edge in pixels.
void
setParcelableData(Parcelable parcelableData)
Sets the Parcelable
data of the event.
void
setPassword(boolean isPassword)
Sets if the source is a password field.
void
setRemovedCount(int removedCount)
Sets the number of removed characters.
void
setScrollX(int scrollX)
Sets the scroll offset of the source left edge in pixels.
void
setScrollY(int scrollY)
Sets the scroll offset of the source top edge in pixels.
void
setScrollable(boolean scrollable)
Sets if the source is scrollable.
void
setSource(View root, int virtualDescendantId)
Sets the source to be a virtual descendant of the given root
.
void
setSource(View source)
Sets the event source.
void
setToIndex(int toIndex)
Sets the index of text selection end or the index of the last visible item when scrolling.
String
toString()
Returns a string representation of the object.
Inherited methods
java.lang.Object
Public methods
getAddedCount
int getAddedCount ()
Gets the number of added characters.
int
The number of added characters.getBeforeText
CharSequence getBeforeText ()
Sets the text before a change.
CharSequence
The text before the change.getClassName
CharSequence getClassName ()
Gets the class name of the source.
CharSequence
The class name.getContentDescription
CharSequence getContentDescription ()
Gets the description of the source.
CharSequence
The description.getCurrentItemIndex
int getCurrentItemIndex ()
Gets the index of the source in the list of items the can be visited.
int
The current item index.getFromIndex
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.
int
The index of the first character or selection start or the first visible item.getItemCount
int getItemCount ()
Gets the number of items that can be visited.
int
The number of items.getMaxScrollX
int getMaxScrollX ()
Gets the max scroll offset of the source left edge in pixels.
int
The max scroll.getMaxScrollY
int getMaxScrollY ()
Gets the max scroll offset of the source top edge in pixels.
int
The max scroll.getParcelableData
Parcelable getParcelableData ()
Gets the Parcelable
data.
Parcelable
The parcelable data.getRemovedCount
int getRemovedCount ()
Gets the number of removed characters.
int
The number of removed characters.getScrollX
int getScrollX ()
Gets the scroll offset of the source left edge in pixels.
int
The scroll.getScrollY
int getScrollY ()
Gets the scroll offset of the source top edge in pixels.
int
The scroll.getSource
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.
AccessibilityNodeInfo
The info of the source.getText
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.
List<CharSequence>
The text.getToIndex
int getToIndex ()
Gets the index of text selection end or the index of the last visible item when scrolling.
int
The index of selection end or last item index.getWindowId
int getWindowId ()
Gets the id of the window from which the event comes from.
int
The window id.isChecked
boolean isChecked ()
Gets if the source is checked.
boolean
True if the view is checked, false otherwise.isEnabled
boolean isEnabled ()
Gets if the source is enabled.
boolean
True if the view is enabled, false otherwise.isFullScreen
boolean isFullScreen ()
Gets if the source is taking the entire screen.
boolean
True if the source is full screen, false otherwise.isPassword
boolean isPassword ()
Gets if the source is a password field.
boolean
True if the view is a password field, false otherwise.isScrollable
boolean isScrollable ()
Gets if the source is scrollable.
boolean
True if the source is scrollable, false otherwise.obtain
AccessibilityRecord obtain ()
Returns a cached instance if such is available or a new one is instantiated.
AccessibilityRecord
An instance.obtain
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.
record
AccessibilityRecord
AccessibilityRecord
An instance.recycle
void recycle ()
Return an instance back to be reused.
Note: You must not touch the object after calling this function.
IllegalStateException
If the record is already recycled.setAddedCount
void setAddedCount (int addedCount)
Sets the number of added characters.
addedCount
int
: The number of added characters.IllegalStateException
If called from an AccessibilityService.setBeforeText
void setBeforeText (CharSequence beforeText)
Sets the text before a change.
beforeText
CharSequence
: The text before the change.IllegalStateException
If called from an AccessibilityService.setChecked
void setChecked (boolean isChecked)
Sets if the source is checked.
isChecked
boolean
: True if the view is checked, false otherwise.IllegalStateException
If called from an AccessibilityService.setClassName
void setClassName (CharSequence className)
Sets the class name of the source.
className
CharSequence
: The lass name.IllegalStateException
If called from an AccessibilityService.setContentDescription
void setContentDescription (CharSequence contentDescription)
Sets the description of the source.
contentDescription
CharSequence
: The description.IllegalStateException
If called from an AccessibilityService.setCurrentItemIndex
void setCurrentItemIndex (int currentItemIndex)
Sets the index of the source in the list of items that can be visited.
currentItemIndex
int
: The current item index.IllegalStateException
If called from an AccessibilityService.setEnabled
void setEnabled (boolean isEnabled)
Sets if the source is enabled.
isEnabled
boolean
: True if the view is enabled, false otherwise.IllegalStateException
If called from an AccessibilityService.setFromIndex
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.
fromIndex
int
: The index of the first character or selection start or the first visible item.IllegalStateException
If called from an AccessibilityService.setFullScreen
void setFullScreen (boolean isFullScreen)
Sets if the source is taking the entire screen.
isFullScreen
boolean
: True if the source is full screen, false otherwise.IllegalStateException
If called from an AccessibilityService.setItemCount
void setItemCount (int itemCount)
Sets the number of items that can be visited.
itemCount
int
: The number of items.IllegalStateException
If called from an AccessibilityService.setMaxScrollX
void setMaxScrollX (int maxScrollX)
Sets the max scroll offset of the source left edge in pixels.
maxScrollX
int
: The max scroll.setMaxScrollY
void setMaxScrollY (int maxScrollY)
Sets the max scroll offset of the source top edge in pixels.
maxScrollY
int
: The max scroll.setParcelableData
void setParcelableData (Parcelable parcelableData)
Sets the Parcelable
data of the event.
parcelableData
Parcelable
: The parcelable data.IllegalStateException
If called from an AccessibilityService.setPassword
void setPassword (boolean isPassword)
Sets if the source is a password field.
isPassword
boolean
: True if the view is a password field, false otherwise.IllegalStateException
If called from an AccessibilityService.setRemovedCount
void setRemovedCount (int removedCount)
Sets the number of removed characters.
removedCount
int
: The number of removed characters.IllegalStateException
If called from an AccessibilityService.setScrollX
void setScrollX (int scrollX)
Sets the scroll offset of the source left edge in pixels.
scrollX
int
: The scroll.setScrollY
void setScrollY (int scrollY)
Sets the scroll offset of the source top edge in pixels.
scrollY
int
: The scroll.setScrollable
void setScrollable (boolean scrollable)
Sets if the source is scrollable.
scrollable
boolean
: True if the source is scrollable, false otherwise.IllegalStateException
If called from an AccessibilityService.setSource
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.
root
View
: The root of the virtual subtree.virtualDescendantId
int
: The id of the virtual descendant.setSource
void setSource (View source)
Sets the event source.
source
View
: The source.IllegalStateException
If called from an AccessibilityService.setToIndex
void setToIndex (int toIndex)
Sets the index of text selection end or the index of the last visible item when scrolling.
toIndex
int
: The index of selection end or last item index.toString
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())
String
a string representation of the object.- android-AccessibilityRecord
- Android
- android
- Android
- android
- android
- Android
- Android
- android
- android
- android
- Android
- Android
- android!!!
- android
- android
- android
- android
- android_弹窗之初入江湖
- C语言八进制 十六进制 十进制之间的ASCII表
- 使用methodSignatureForSelector与forwardInvocation实现消息转发
- 13.2.5 I/O类的抽象和基本功能
- "error while loading shared libraries: xxx.so.x" 错误的原因和解决办法
- android-AccessibilityRecord
- Linux 查看tomcat catlina
- 30个物联网产业动向 芯片商也来抢占IoT
- URLContext结构体
- floyd求最小环
- AVIOContext结构体
- Android水波纹特效的简单实现
- 安卓studio 新建项目时,出现包冲突错误时 ---- 解决办法
- 《算法竞赛入门经典(第二版)》第三章 习题(1-5)