Android Development Notes: How to Screen button setclickable and setenabled_android

Source: Internet
Author: User
Today want to let the button temporarily invalid, meet certain conditions before users can be pressed. Originally thought is setclickable, who knows the mistake.
Please read the manual:
Copy Code code as follows:

public void Setclickable (Boolean clickable)
SINCE:API Level 14
Sets Whether this node is clickable.
Note:cannot is called from the Accessibilityservice. This class is made immutable before being delivered to a accessibilityservice.
Parameters
Clickable True If the node is clickable.
Throws
IllegalStateException If called from Accessibilityservice.
public void Setcontentdescription (Charsequence contentdescr

This function means to press the button. For example, to get a timer, and then simulate on the phone, how long to let the button click on their own, rather than manually to press, you can use this function.
Copy Code code as follows:

public void SetEnabled (Boolean enabled)
SINCE:API Level 14
Sets Whether this node is enabled.
Note:cannot is called from the Accessibilityservice. This class is made immutable before being delivered to a accessibilityservice.
Parameters
Enabled True If the node is enabled.
Throws
IllegalStateException If called from Accessibilityservice.

This function is true, so that a button can be pressed by the user, or not. If set to False, the key will turn gray and no response. When set to true, it will not work properly. This is the function I'm looking for.
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.