Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android View performClick() and callOnClick() difference

Tags:

java

android

view

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?

like image 302
Romans Stepanovs Avatar asked Aug 15 '13 09:08

Romans Stepanovs


People also ask

What is use of Callonclick in Android?

Performs all normal actions associated with clicking: reporting accessibility event, playing a sound, etc. 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. MH.

What does PerformClick do?

PerformClick rather than invoking the click event of a button directly. The MSDN documentation simply says: Generates a Click event for a button.


1 Answers

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.

like image 101
MH. Avatar answered Sep 30 '22 18:09

MH.