Set OnClickListener off and then on

2019-04-21 02:14发布

I am setting the OnClickListener off after the user has clicked on the button.

confirm.setOnClickListener(null);

This makes the button unclickable but I want it to be clickable after the user has clicked another button.

How can I do this?

2条回答
Juvenile、少年°
2楼-- · 2019-04-21 02:59

Simply

confirm.setOnClickListener(myOnClickListener);

Where myOnClickListener is your OnClickListener that you used before! This line of code would need to go in the OnClickListener for the 're-activation' button.

查看更多
男人必须洒脱
3楼-- · 2019-04-21 03:12

Just set

confirm.setClickable(false); to disable and confirm.setClickable(true) to enable it again.

See Here

查看更多
登录 后发表回答