国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > Android > 正文

Android開發筆記之:如何屏蔽Button setClickable與setEnabled

2020-04-11 12:19:27
字體:
來源:轉載
供稿:網友
今天想讓按鍵暫時無效,滿足一定條件下才可以被用戶按到。最初以為是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后,才會正常使用。這正是我找的函數。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 平昌县| 离岛区| 开化县| 类乌齐县| 廊坊市| 阳城县| 景泰县| 岑溪市| 绍兴县| 天水市| 墨江| 澜沧| 堆龙德庆县| 迁西县| 巴东县| 新宾| 建始县| 晴隆县| 乐平市| 景洪市| 井研县| 安溪县| 金沙县| 临夏县| 周宁县| 南昌市| 红原县| 唐海县| 大名县| 乌鲁木齐市| 阿拉善左旗| 榆社县| 绥滨县| 宿州市| 鲁山县| 丰镇市| 白水县| 上林县| 奇台县| 武邑县| 如皋市|