删除一个onclick监听器 [英] Remove an onclick listener

查看:410
本文介绍了删除一个onclick监听器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在文本周期和显示状态信息的对象。当信息的变化,我想对象的Click事件来改变带你到该消息被有关活动。

I have an object where the text cycles and displays status messages. When the messages change, I want the click event of the object to change to take you to the activity that the message is relating to.

所以,我有一个 TextView的mTitleView ,我分配的情况下是这样的。

So, I have a TextView mTitleView and I'm assigning the event like this.

public void setOnTitleClickListener(OnClickListener listener) {
    mTitleView.setOnClickListener(listener);
}

我如何删除单击事件?有没有一个可操作的区域,所以我想关闭单击事件的一些状态信息。我还希望能够循环通过这些点击事件和妥善处置他们,但我不能确定的最佳实践。

How do I remove that click event? There are some status messages that do not have an actionable area so I'd like to turn off the click event. I'd also like to be able to cycle through these click events and dispose of them properly, but I'm unsure of the best practice.

推荐答案

mTitleView.setOnClickListener(空)应该做的伎俩。

有一个更好的设计可能会做的OnClickListener状态的检查,然后确定点击是否应该做一些VS增加及结算所点击的听众。

A better design might be to do a check of the status in the OnClickListener and then determine whether or not the click should do something vs adding and clearing click listeners.

这篇关于删除一个onclick监听器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆