Join Slack
Powered by
I defined onClick="internal" in button and when I ...
# android
k
Ketan Khunti
07/20/2021, 3:57 AM
I defined onClick="internal" in button and when I use fun internal(v:VIEW) {} then it is working but when I define function like fun internal() {} then it isn't working. Can anyone explain why it is so ?
😶 4
d
Divyanshu Kunwar
07/20/2021, 5:38 AM
I think you missed the arguments v:View
k
Ketan Khunti
07/20/2021, 5:40 AM
That's what I am asking that why is it necessary?
e
ephemient
07/20/2021, 7:54 AM
1. this is not a kotlin question, it is the exact same in java 2.
https://developer.android.com/reference/android/view/View#attr_android:onClick
it is documented 3.
https://cs.android.com/android/platform/superproject/+/master:frameworks/base/core/java/android/view/View.java;l=6273;drc=master;bpv=0;bpt=1?q=DeclaredOnClickListener.resolveMethod&sq=&ss=android%2Fplatform%2Fsuperproject
that is how the method is found by reflection
ephemient
07/20/2021, 7:57 AM
anyway, don't use it. it goes along with a "god activity" which handles everything, but that is not recommended modern app design.
12
Views
Open in Slack
Previous
Next