Android View performClick() and callOnClick() difference

JavaAndroidView

Java Problem Overview


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?

Java Solutions


Solution 1 - Java

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionRomans StepanovsView Question on Stackoverflow
Solution 1 - JavaMH.View Answer on Stackoverflow