Defined:
The so-called callback means that a program has a function A, I call the B function in this program, I want the B function to call my a function, this a function is called the callback function. (Read the Internet for a long time to understand 0-0)
C + + for callback implementations:
For example, I call Qsort (A,A+N,CMP) in the program, where a is an array, n is the number of array elements, and the CMP function is defined within its own program. I want qsort to call my CMP function, so I'm going to pass the CMP function pointer to qsort so that qsort can call my CMP function. This implements the callback, and this CMP function is called the callback function.
Android's implementation of callbacks:
For Java, the use of a function pointer, so the use of an interface to implement a function callback, take the button to say it.
A Class A implements the Onclicklistener interface, the onclick () method is implemented, and a wants the button to invoke the OnClick () method of a, so that the button object's Setonclicklistener is called First ( The Onclicklistener L) method passes an object that implements Onclicklistener to the button (the button class must have a onclicklistener reference), so through this reference, The button can invoke the OnClick () method of a, and the callback is implemented.
Understanding for a long time, I hope that the great God to teach you.
Understanding of the Android callback mechanism