Android 查看 performClick() 和 callOnClick() 的区别 [英] Android View performClick() and callOnClick() difference
问题描述
performClick()
和 callOnClick()
在用法上有什么区别?看起来都是一样的,那为什么View
有两个方法呢?
这两种方法的 Javadoc 也一目了然:
public boolean performClick()
<块引用>
在 API 级别 1
中添加调用此视图的 OnClickListener(如果已定义).执行所有与点击相关的正常操作:报告可访问性事件、播放声音等
<小时>
public boolean callOnClick()
<块引用>
在 API 级别 15 中添加
直接调用任何附加的 OnClickListener.与 performClick() 不同,这仅调用侦听器,不执行任何关联的单击报告无障碍事件等操作.
What is the difference in usage between performClick()
and callOnClick()
? It seems that they work the same way, then why does View
have two methods?
The Javadoc for both methods is pretty self-explanatory too:
public boolean performClick ()
Added in API level 1
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 ()
Added in API level 15
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 查看 performClick() 和 callOnClick() 的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!