今天想讓按鍵暫時無效,滿足一定條件下才可以被使用者按到。最初以為是setClickable,誰知搞錯了。
請看手冊:
複製代碼 代碼如下:public void setClickable (boolean clickable)
Since: API Level 14
Sets whether this node is clickable.
Note: Cannot be called from an AccessibilityService. This class is made immutable before being delivered to an AccessibilityService.
Parameters
clickable True if the node is clickable.
Throws
IllegalStateException If called from an AccessibilityService.
public void setContentDescription (CharSequence contentDescr
這個函數的意思是讓按鍵按一下。比如弄一個定時器,然後在手機上類比,多長時間到了讓按鍵自己按一下,而不是手動去按,可以用這個函數。複製代碼 代碼如下:public void setEnabled (boolean enabled)
Since: API Level 14
Sets whether this node is enabled.
Note: Cannot be called from an AccessibilityService. This class is made immutable before being delivered to an AccessibilityService.
Parameters
enabled True if the node is enabled.
Throws
IllegalStateException If called from an AccessibilityService.
這個函數才是真正的,讓一個按鍵可以被使用者按,或者不可按。如果設為false,按鍵則會變成灰色的,按上去也沒反應。當設為true後,才會正常使用。這正是我找的函數。