java - How does the android Xml attribute android:onClick="..." work behind the scenes? -


i'm asking little because im intrested , because im afraid use properties\code don't understand. understand events in java work implementing listener inteface thats appropriate event. happen if implement onclick in activity 2 buttons , third define method android:onclick="..." property? found article, after reading understand probebly implemented using anonymous class implements onclicklistener, i'd sure\know more it, , in way might break something\ use knowledge advantege? android reference isn't clear how works,,,

it uses reflection figure out method call @ runtime. it's view's property, view has relevant code looks if property set, , figure out method name on activity , triggers it.

view bound specific activity's context, , so, able call public method through reflection.

you can see source code of view class here. can see line number 2003, situation being handled.

source code view class


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -