Android ViewperformClick()和callOnClick()的区别 [英] Android View performClick() and callOnClick() difference

查看:936
本文介绍了Android ViewperformClick()和callOnClick()的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我认为标题是不言自明的. performClick()callOnClick()方法之间的用法有何区别? 看来它们的工作方式相同,那么为什么View那么有两种方法呢?

I think the title is self-explanatory. What is the difference in usage between the performClick() and callOnClick() methods? It seems that they work the same way, so why does View have two methods then?

推荐答案

这两种方法的Javadoc也很容易解释:

The Javadoc for both methods is pretty self-explanatory too:

public boolean performClick ()

已添加到API级别 1

调用此视图的OnClickListener(如果已定义). 执行全部 与点击相关的常规操作:报告可访问性 活动,播放声音等

Call this view's OnClickListener, if it is defined. Performs all normal actions associated with clicking: reporting accessibility event, playing a sound, etc.


public boolean callOnClick ()

已添加到API级别 15

直接调用任何附加的OnClickListener. 与performClick()不同, 这只会调用侦听器,并且不会进行任何关联的点击 诸如报告可访问性事件之类的操作.

Directly call any attached OnClickListener. Unlike performClick(), this only calls the listener, and does not do any associated clicking actions like reporting an accessibility event.

这篇关于Android ViewperformClick()和callOnClick()的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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