Android development Note: How to shield Button setClickable and setEnabled

Source: Internet
Author: User

Today, if you want to temporarily disable the buttons, you can press them only when certain conditions are met. At first, I thought it was setClickable.
Please refer to the manual: Copy codeThe Code is as follows: 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

This function means to press the button. For example, if you want to set a timer and simulate it on your phone, you can use this function to press the button instead of manually.Copy codeThe Code is as follows: 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.

This function is true, so that a button can be pressed or not pressed by the user. If it is set to false, the button turns gray and does not respond when it is pressed. If it is set to true, it will be used normally. This is the function I am looking.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.