AccessibilityAction API文档

https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.AccessibilityAction

AccessibilityNodeInfo.AccessibilityAction

Kotlin |Java

public static final class AccessibilityNodeInfo.AccessibilityAction
extends Object implements Parcelable

java.lang.Object
   ↳android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction


A class defining an action that can be performed on an AccessibilityNodeInfo. Each action has a unique id that is mandatory and optional data.

There are three categories of actions:

  • Standard actions - These are actions that are reported and handled by the standard UI widgets in the platform. For each standard action there is a static constant defined in this class, e.g. ACTION_FOCUS. These actions will have null labels.
  • Custom actions action - These are actions that are reported and handled by custom widgets. i.e. ones that are not part of the UI toolkit. For example, an application may define a custom action for clearing the user history.
  • Overriden standard actions - These are actions that override standard actions to customize them. For example, an app may add a label to the standard ACTION_CLICK action to indicate to the user that this action clears browsing history.

Actions are typically added to an AccessibilityNodeInfo by using AccessibilityNodeInfo#addAction(AccessibilityAction) within View#onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo) and are performed within View#performAccessibilityAction(int, Bundle).

Note: Views which support these actions should invoke View#setImportantForAccessibility(int) with View#IMPORTANT_FOR_ACCESSIBILITY_YES to ensure an AccessibilityService can discover the set of supported actions.

Summary

Inherited constants

From interface android.os.Parcelable

Fields

public static final AccessibilityNodeInfo.AccessibilityActionACTION_ACCESSIBILITY_FOCUS

Action that gives accessibility focus to the node.

public static final AccessibilityNodeInfo.AccessibilityActionACTION_CLEAR_ACCESSIBILITY_FOCUS

Action that clears accessibility focus of the node.

public static final AccessibilityNodeInfo.AccessibilityActionACTION_CLEAR_FOCUS

Action that clears input focus of the node.

public static final AccessibilityNodeInfo.AccessibilityActionACTION_CLEAR_SELECTION

Action that deselects the node.

public static final AccessibilityNodeInfo.AccessibilityActionACTION_CLICK

Action that clicks on the node info.

public static final AccessibilityNodeInfo.AccessibilityActionACTION_COLLAPSE

Action to collapse an expandable node.

public static final AccessibilityNodeInfo.AccessibilityActionACTION_CONTEXT_CLICK

Action that context clicks the node.

public static final AccessibilityNodeInfo.AccessibilityActionACTION_COPY

Action to copy the current selection to the clipboard.

public static final AccessibilityNodeInfo.AccessibilityActionACTION_CUT

Action to cut the current selection and place it to the clipboard.

public static final AccessibilityNodeInfo.AccessibilityActionACTION_DISMISS

Action to dismiss a dismissable node.

public static final AccessibilityNodeInfo.AccessibilityActionACTION_DRAG_CANCEL

Action to cancel a drag.

public static final AccessibilityNodeInfo.AccessibilityActionACTION_DRAG_DROP

Action to trigger a drop of the content being dragged.

public static final AccessibilityNodeInfo.AccessibilityActionACTION_DRAG_START

Action to start a drag.

public static final AccessibilityNodeInfo.AccessibilityActionACTION_EXPAND

Action to expand an expandable node.

public static final AccessibilityNodeInfo.AccessibilityActionACTION_FOCUS

Action that gives input focus to the node.

public static final AccessibilityNodeInfo.AccessibilityActionACTION_HIDE_TOOLTIP

Action to hide a tooltip.

public static final AccessibilityNodeInfo.AccessibilityActionACTION_IME_ENTER

Action to send an ime actionId which is from EditorInfo.actionId.

public static final AccessibilityNodeInfo.AccessibilityActionACTION_LONG_CLICK

Action that long clicks on the node.

public static final AccessibilityNodeInfo.AccessibilityActionACTION_MOVE_WINDOW

Action to move a window to a new location.

public static final AccessibilityNodeInfo.AccessibilityActionACTION_NEXT_AT_MOVEMENT_GRANULARITY

Action that requests to go to the next entity in this node's text at a given movement granularity.

public static final AccessibilityNodeInfo.AccessibilityActionACTION_NEXT_HTML_ELEMENT

Action to move to the next HTML element of a given type.

public static final AccessibilityNodeInfo.AccessibilityActionACTION_PAGE_DOWN

Action to move to the page below.

public static final AccessibilityNodeInfo.AccessibilityActionACTION_PAGE_LEFT

Action to move to the page left.

public static final AccessibilityNodeInfo.AccessibilityActionACTION_PAGE_RIGHT

Action to move to the page right.

public static final AccessibilityNodeInfo.AccessibilityActionACTION_PAGE_UP

Action to move to the page above.

public static final AccessibilityNodeInfo.AccessibilityActionACTION_PASTE

Action to paste the current clipboard content.

public static final AccessibilityNodeInfo.AccessibilityActionACTION_PRESS_AND_HOLD

Action that presses and holds a node.

public static final AccessibilityNodeInfo.AccessibilityActionACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY

Action that requests to go to the previous entity in this node's text at a given movement granularity.

public static final AccessibilityNodeInfo.AccessibilityActionACTION_PREVIOUS_HTML_ELEMENT

Action to move to the previous HTML element of a given type.

public static final AccessibilityNodeInfo.AccessibilityActionACTION_SCROLL_BACKWARD

Action to scroll the node content backward.

public static final AccessibilityNodeInfo.AccessibilityActionACTION_SCROLL_DOWN

Action to scroll the node content down.

public static final AccessibilityNodeInfo.AccessibilityActionACTION_SCROLL_FORWARD

Action to scroll the node content forward.

public static final AccessibilityNodeInfo.AccessibilityActionACTION_SCROLL_LEFT

Action to scroll the node content left.

public static final AccessibilityNodeInfo.AccessibilityActionACTION_SCROLL_RIGHT

Action to scroll the node content right.

public static final AccessibilityNodeInfo.AccessibilityActionACTION_SCROLL_TO_POSITION

Action that scrolls the node to make the specified collection position visible on screen.

public static final AccessibilityNodeInfo.AccessibilityActionACTION_SCROLL_UP

Action to scroll the node content up.

public static final AccessibilityNodeInfo.AccessibilityActionACTION_SELECT

Action that selects the node.

public static final AccessibilityNodeInfo.AccessibilityActionACTION_SET_PROGRESS

Action that sets progress between RangeInfo.getMin() and RangeInfo.getMax().

public static final AccessibilityNodeInfo.AccessibilityActionACTION_SET_SELECTION

Action to set the selection.

public static final AccessibilityNodeInfo.AccessibilityActionACTION_SET_TEXT

Action that sets the text of the node.

public static final AccessibilityNodeInfo.AccessibilityActionACTION_SHOW_ON_SCREEN

Action that requests the node make its bounding rectangle visible on the screen, scrolling if necessary just enough.

public static final AccessibilityNodeInfo.AccessibilityActionACTION_SHOW_SUGGESTIONS

Action to show suggestions for editable text.

public static final AccessibilityNodeInfo.AccessibilityActionACTION_SHOW_TOOLTIP

Action to show a tooltip.

public static final AccessibilityNodeInfo.AccessibilityActionACTION_SWIPE_DOWN

Action to perform a down swipe.

public static final AccessibilityNodeInfo.AccessibilityActionACTION_SWIPE_LEFT

Action to perform a left swipe.

public static final AccessibilityNodeInfo.AccessibilityActionACTION_SWIPE_RIGHT

Action to perform a right swipe.

public static final AccessibilityNodeInfo.AccessibilityActionACTION_SWIPE_UP

Action to perform an up swipe.

public static final Creator<AccessibilityNodeInfo.AccessibilityAction>CREATOR

Public constructors

AccessibilityAction(int actionId, CharSequence label)

Creates a new AccessibilityAction.

Public methods

intdescribeContents()

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation.

booleanequals(Object other)

Indicates whether some other object is "equal to" this one.

intgetId()

Gets the id for this action.

CharSequencegetLabel()

Gets the label for this action.

inthashCode()

Returns a hash code value for the object.

StringtoString()

Returns a string representation of the object.

voidwriteToParcel(Parcel out, int flags)

Write data into a parcel.

Inherited methods

From class java.lang.Object
From interface android.os.Parcelable

Fields

ACTION_ACCESSIBILITY_FOCUS

Added in API level 21

public static final AccessibilityNodeInfo.AccessibilityAction ACTION_ACCESSIBILITY_FOCUS

Action that gives accessibility focus to the node.

ACTION_CLEAR_ACCESSIBILITY_FOCUS

Added in API level 21

public static final AccessibilityNodeInfo.AccessibilityAction ACTION_CLEAR_ACCESSIBILITY_FOCUS

Action that clears accessibility focus of the node.

ACTION_CLEAR_FOCUS

Added in API level 21

public static final AccessibilityNodeInfo.AccessibilityAction ACTION_CLEAR_FOCUS

Action that clears input focus of the node.

ACTION_CLEAR_SELECTION

Added in API level 21

public static final AccessibilityNodeInfo.AccessibilityAction ACTION_CLEAR_SELECTION

Action that deselects the node.

ACTION_CLICK

Added in API level 21

public static final AccessibilityNodeInfo.AccessibilityAction ACTION_CLICK

Action that clicks on the node info.

ACTION_COLLAPSE

Added in API level 21

public static final AccessibilityNodeInfo.AccessibilityAction ACTION_COLLAPSE

Action to collapse an expandable node.

ACTION_CONTEXT_CLICK

Added in API level 23

public static final AccessibilityNodeInfo.AccessibilityAction ACTION_CONTEXT_CLICK

Action that context clicks the node.

ACTION_COPY

Added in API level 21

public static final AccessibilityNodeInfo.AccessibilityAction ACTION_COPY

Action to copy the current selection to the clipboard.

ACTION_CUT

Added in API level 21

public static final AccessibilityNodeInfo.AccessibilityAction ACTION_CUT

Action to cut the current selection and place it to the clipboard.

ACTION_DISMISS

Added in API level 21

public static final AccessibilityNodeInfo.AccessibilityAction ACTION_DISMISS

Action to dismiss a dismissable node.

ACTION_DRAG_CANCEL

Added in API level 32

public static final AccessibilityNodeInfo.AccessibilityAction ACTION_DRAG_CANCEL

Action to cancel a drag.

This action is added to the source that started a drag with ACTION_DRAG_START.

See also:

ACTION_DRAG_DROP

Added in API level 32

public static final AccessibilityNodeInfo.AccessibilityAction ACTION_DRAG_DROP

Action to trigger a drop of the content being dragged.

This action is added to potential drop targets if the source started a drag with ACTION_DRAG_START. In View, these targets are Views that accepted DragEvent.ACTION_DRAG_STARTED and have an View.OnDragListener.

See also:

ACTION_DRAG_START

Added in API level 32

public static final AccessibilityNodeInfo.AccessibilityAction ACTION_DRAG_START

Action to start a drag.

This action initiates a drag & drop within the system. The source's dragged content is prepared before the drag begins. In View, this action should prepare the arguments to View#startDragAndDrop(ClipData, View.DragShadowBuilder, Object, int) and then call View#startDragAndDrop(ClipData, View.DragShadowBuilder, Object, int). The equivalent should be performed for other UI toolkits.

See also:

ACTION_EXPAND

Added in API level 21

public static final AccessibilityNodeInfo.AccessibilityAction ACTION_EXPAND

Action to expand an expandable node.

ACTION_FOCUS

Added in API level 21

public static final AccessibilityNodeInfo.AccessibilityAction ACTION_FOCUS

Action that gives input focus to the node.

ACTION_HIDE_TOOLTIP

Added in API level 28

public static final AccessibilityNodeInfo.AccessibilityAction ACTION_HIDE_TOOLTIP

Action to hide a tooltip. A node should expose this action only for views that are currently showing a tooltip.

ACTION_IME_ENTER

Added in API level 30

public static final AccessibilityNodeInfo.AccessibilityAction ACTION_IME_ENTER

Action to send an ime actionId which is from EditorInfo.actionId. This ime actionId sets by TextView#setImeActionLabel(CharSequence, int), or it would be EditorInfo.IME_ACTION_UNSPECIFIED if no specific actionId has set. A node should expose this action only for views that are currently with input focus and editable.

ACTION_LONG_CLICK

Added in API level 21

public static final AccessibilityNodeInfo.AccessibilityAction ACTION_LONG_CLICK

Action that long clicks on the node.

ACTION_MOVE_WINDOW

Added in API level 26

public static final AccessibilityNodeInfo.AccessibilityAction ACTION_MOVE_WINDOW

Action to move a window to a new location.

Arguments: AccessibilityNodeInfo#ACTION_ARGUMENT_MOVE_WINDOW_X AccessibilityNodeInfo#ACTION_ARGUMENT_MOVE_WINDOW_Y

ACTION_NEXT_AT_MOVEMENT_GRANULARITY

Added in API level 21

public static final AccessibilityNodeInfo.AccessibilityAction ACTION_NEXT_AT_MOVEMENT_GRANULARITY

Action that requests to go to the next entity in this node's text at a given movement granularity. For example, move to the next character, word, etc.

Arguments: AccessibilityNodeInfo.ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INTAccessibilityNodeInfo.ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN
Example: Move to the previous character and do not extend selection.

 

Bundle arguments = new Bundle(); arguments.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT, AccessibilityNodeInfo.MOVEMENT_GRANULARITY_CHARACTER); arguments.putBoolean(AccessibilityNodeInfo.ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN, false); info.performAction(AccessibilityAction.ACTION_NEXT_AT_MOVEMENT_GRANULARITY.getId(), arguments);

See also:

ACTION_NEXT_HTML_ELEMENT

Added in API level 21

public static final AccessibilityNodeInfo.AccessibilityAction ACTION_NEXT_HTML_ELEMENT

Action to move to the next HTML element of a given type. For example, move to the BUTTON, INPUT, TABLE, etc.

Arguments: AccessibilityNodeInfo.ACTION_ARGUMENT_HTML_ELEMENT_STRING
Example:

 

Bundle arguments = new Bundle(); arguments.putString(AccessibilityNodeInfo.ACTION_ARGUMENT_HTML_ELEMENT_STRING, "BUTTON"); info.performAction(AccessibilityAction.ACTION_NEXT_HTML_ELEMENT.getId(), arguments);

ACTION_PAGE_DOWN

Added in API level 29

public static final AccessibilityNodeInfo.AccessibilityAction ACTION_PAGE_DOWN

Action to move to the page below.

ACTION_PAGE_LEFT

Added in API level 29

public static final AccessibilityNodeInfo.AccessibilityAction ACTION_PAGE_LEFT

Action to move to the page left.

ACTION_PAGE_RIGHT

Added in API level 29

public static final AccessibilityNodeInfo.AccessibilityAction ACTION_PAGE_RIGHT

Action to move to the page right.

ACTION_PAGE_UP

Added in API level 29

public static final AccessibilityNodeInfo.AccessibilityAction ACTION_PAGE_UP

Action to move to the page above.

ACTION_PASTE

Added in API level 21

public static final AccessibilityNodeInfo.AccessibilityAction ACTION_PASTE

Action to paste the current clipboard content.

ACTION_PRESS_AND_HOLD

Added in API level 30

public static final AccessibilityNodeInfo.AccessibilityAction ACTION_PRESS_AND_HOLD

Action that presses and holds a node.

This action is for nodes that have distinct behavior that depends on how long a press is held. Nodes having a single action for long press should use ACTION_LONG_CLICK instead of this action, and nodes should not expose both actions.

When calling performAction(ACTION_PRESS_AND_HOLD, bundle, use AccessibilityNodeInfo.ACTION_ARGUMENT_PRESS_AND_HOLD_DURATION_MILLIS_INT to specify how long the node is pressed. The first time an accessibility service performs ACTION_PRES_AND_HOLD on a node, it must specify 0 as ACTION_ARGUMENT_PRESS_AND_HOLD, so the application is notified that the held state has started. To ensure reasonable behavior, the values must be increased incrementally and may not exceed 10,000. UIs requested to hold for times outside of this range should ignore the action.

The total time the element is held could be specified by an accessibility user up-front, or may depend on what happens on the UI as the user continues to request the hold.

Note: The time between dispatching the action and it arriving in the UI process is not guaranteed. It is possible on a busy system for the time to expire unexpectedly. For the case of holding down a key for a repeating action, a delayed arrival should be benign. Please do not use this sort of action in cases where such delays will lead to unexpected UI behavior.

ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY

Added in API level 21

public static final AccessibilityNodeInfo.AccessibilityAction ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY

Action that requests to go to the previous entity in this node's text at a given movement granularity. For example, move to the next character, word, etc.

Arguments: AccessibilityNodeInfo.ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INTAccessibilityNodeInfo.ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN
Example: Move to the next character and do not extend selection.

 

Bundle arguments = new Bundle(); arguments.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT, AccessibilityNodeInfo.MOVEMENT_GRANULARITY_CHARACTER); arguments.putBoolean(AccessibilityNodeInfo.ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN, false); info.performAction(AccessibilityAction.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY.getId(), arguments);

See also:

ACTION_PREVIOUS_HTML_ELEMENT

Added in API level 21

public static final AccessibilityNodeInfo.AccessibilityAction ACTION_PREVIOUS_HTML_ELEMENT

Action to move to the previous HTML element of a given type. For example, move to the BUTTON, INPUT, TABLE, etc.

Arguments: AccessibilityNodeInfo.ACTION_ARGUMENT_HTML_ELEMENT_STRING
Example:

 

Bundle arguments = new Bundle(); arguments.putString(AccessibilityNodeInfo.ACTION_ARGUMENT_HTML_ELEMENT_STRING, "BUTTON"); info.performAction(AccessibilityAction.ACTION_PREVIOUS_HTML_ELEMENT.getId(), arguments);

ACTION_SCROLL_BACKWARD

Added in API level 21

public static final AccessibilityNodeInfo.AccessibilityAction ACTION_SCROLL_BACKWARD

Action to scroll the node content backward.

ACTION_SCROLL_DOWN

Added in API level 23

public static final AccessibilityNodeInfo.AccessibilityAction ACTION_SCROLL_DOWN

Action to scroll the node content down.

ACTION_SCROLL_FORWARD

Added in API level 21

public static final AccessibilityNodeInfo.AccessibilityAction ACTION_SCROLL_FORWARD

Action to scroll the node content forward.

ACTION_SCROLL_LEFT

Added in API level 23

public static final AccessibilityNodeInfo.AccessibilityAction ACTION_SCROLL_LEFT

Action to scroll the node content left.

ACTION_SCROLL_RIGHT

Added in API level 23

public static final AccessibilityNodeInfo.AccessibilityAction ACTION_SCROLL_RIGHT

Action to scroll the node content right.

ACTION_SCROLL_TO_POSITION

Added in API level 23

public static final AccessibilityNodeInfo.AccessibilityAction ACTION_SCROLL_TO_POSITION

Action that scrolls the node to make the specified collection position visible on screen.

Arguments:

ACTION_SCROLL_UP

Added in API level 23

public static final AccessibilityNodeInfo.AccessibilityAction ACTION_SCROLL_UP

Action to scroll the node content up.

ACTION_SELECT

Added in API level 21

public static final AccessibilityNodeInfo.AccessibilityAction ACTION_SELECT

Action that selects the node.

ACTION_SET_PROGRESS

Added in API level 24

public static final AccessibilityNodeInfo.AccessibilityAction ACTION_SET_PROGRESS

Action that sets progress between RangeInfo.getMin() and RangeInfo.getMax(). It should use the same value type as RangeInfo.getType()

Arguments: AccessibilityNodeInfo#ACTION_ARGUMENT_PROGRESS_VALUE

See also:

ACTION_SET_SELECTION

Added in API level 21

public static final AccessibilityNodeInfo.AccessibilityAction ACTION_SET_SELECTION

Action to set the selection. Performing this action with no arguments clears the selection.

Arguments: AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_START_INTAccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_END_INT
Example:

 

Bundle arguments = new Bundle(); arguments.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_START_INT, 1); arguments.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_END_INT, 2); info.performAction(AccessibilityAction.ACTION_SET_SELECTION.getId(), arguments);

See also:

ACTION_SET_TEXT

Added in API level 21

public static final AccessibilityNodeInfo.AccessibilityAction ACTION_SET_TEXT

Action that sets the text of the node. Performing the action without argument, using null or empty CharSequence will clear the text. This action will also put the cursor at the end of text.

Arguments: AccessibilityNodeInfo.ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE
Example:

 

Bundle arguments = new Bundle(); arguments.putCharSequence(AccessibilityNodeInfo.ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE, "android"); info.performAction(AccessibilityAction.ACTION_SET_TEXT.getId(), arguments);

ACTION_SHOW_ON_SCREEN

Added in API level 23

public static final AccessibilityNodeInfo.AccessibilityAction ACTION_SHOW_ON_SCREEN

Action that requests the node make its bounding rectangle visible on the screen, scrolling if necessary just enough.

See also:

ACTION_SHOW_SUGGESTIONS

Added in Android Tiramisu

public static final AccessibilityNodeInfo.AccessibilityAction ACTION_SHOW_SUGGESTIONS

Action to show suggestions for editable text.

ACTION_SHOW_TOOLTIP

Added in API level 28

public static final AccessibilityNodeInfo.AccessibilityAction ACTION_SHOW_TOOLTIP

Action to show a tooltip. A node should expose this action only for views with tooltip text that but are not currently showing a tooltip.

ACTION_SWIPE_DOWN

Added in Android Tiramisu

public static final AccessibilityNodeInfo.AccessibilityAction ACTION_SWIPE_DOWN

Action to perform a down swipe.

ACTION_SWIPE_LEFT

Added in Android Tiramisu

public static final AccessibilityNodeInfo.AccessibilityAction ACTION_SWIPE_LEFT

Action to perform a left swipe.

ACTION_SWIPE_RIGHT

Added in Android Tiramisu

public static final AccessibilityNodeInfo.AccessibilityAction ACTION_SWIPE_RIGHT

Action to perform a right swipe.

ACTION_SWIPE_UP

Added in Android Tiramisu

public static final AccessibilityNodeInfo.AccessibilityAction ACTION_SWIPE_UP

Action to perform an up swipe.

CREATOR

Added in API level 30

public static final Creator<AccessibilityNodeInfo.AccessibilityAction> CREATOR

Public constructors

AccessibilityAction

Added in API level 21

public AccessibilityAction (int actionId, 
                CharSequence label)

Creates a new AccessibilityAction. For adding a standard action without a specific label, use the static constants. You can also override the description for one the standard actions. Below is an example how to override the standard click action by adding a custom label:

   AccessibilityAction action = new AccessibilityAction(
           AccessibilityAction.ACTION_CLICK.getId(), getLocalizedLabel());
   node.addAction(action);
 

Parameters
actionIdint: The id for this action. This should either be one of the standard actions or a specific action for your app. In that case it is required to use a resource identifier.

labelCharSequence: The label for the new AccessibilityAction. This value may be null.

Public methods

describeContents

Added in API level 30

public int describeContents ()

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. For example, if the object will include a file descriptor in the output of writeToParcel(android.os.Parcel, int), the return value of this method must include the CONTENTS_FILE_DESCRIPTOR bit.

Returns
inta bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either 0 or CONTENTS_FILE_DESCRIPTOR

equals

Added in API level 21

public boolean equals (Object other)

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value xx.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and yx.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values xy, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value xx.equals(null) should return false.

The equals method for class Object implements the most discriminating possible equivalence relation on objects; that is, for any non-null reference values x and y, this method returns true if and only if x and y refer to the same object (x == y has the value true).

Note that it is generally necessary to override the hashCode method whenever this method is overridden, so as to maintain the general contract for the hashCode method, which states that equal objects must have equal hash codes.

Parameters
otherObject: This value may be null.

Returns
booleantrue if this object is the same as the obj argument; false otherwise.

getId

Added in API level 21

public int getId ()

Gets the id for this action.

Returns
intThe action id.

getLabel

Added in API level 21

public CharSequence getLabel ()

Gets the label for this action. Its purpose is to describe the action to user.

Returns
CharSequenceThe label.

hashCode

Added in API level 21

public int hashCode ()

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals(Object) method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals(java.lang.Object) method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.

As much as is reasonably practical, the hashCode method defined by class Object does return distinct integers for distinct objects. (This is typically implemented by converting the internal address of the object into an integer, but this implementation technique is not required by the Java™ programming language.)

Returns
inta hash code value for this object.

toString

Added in API level 21

public 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())
 

Returns
Stringa string representation of the object.

writeToParcel

Added in API level 30

public void writeToParcel (Parcel out, 
                int flags)

Write data into a parcel.

Parameters
outParcel: This value cannot be null.

flagsint: Additional flags about how the object should be written. May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE. Value is either 0 or a combination of Parcelable.PARCELABLE_WRITE_RETURN_VALUE, and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES

 

参与评论 您还未登录,请先 登录 后发表或查看评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
©️2022 CSDN 皮肤主题:大白 设计师:CSDN官方博客 返回首页
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值