It uses reflection to figure out the method to call at runtime. It's a view's property, so the View has the relevant code which looks if this property is set, and then figure out the method name on the activity and triggers it.
View is always bound to a specific activity's context, and so, is able to call this public method through reflection.
You can see the source code of the view class here. You can see line number 2003, where this situation is being handled.
Source code for View class
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…