Handling button click by calling a function(Kotlin, Android Studio) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Handling button click by calling a function(Kotlin, Android Studio)

How do i do this?

15th Jun 2018, 9:27 AM
1337 H4x0r
1337 H4x0r - avatar
5 Answers
+ 1
Thank you!
19th Jun 2018, 7:13 AM
1337 H4x0r
1337 H4x0r - avatar
+ 1
i think that you need to build your function outside, and call the function in the override method(onClick). i am using pure java, i dont realy know much about kotlin but i hope that was helpfull...
19th Jun 2018, 8:10 AM
‎איתן מוצ'ה‎
‎איתן מוצ'ה‎ - avatar
+ 1
oh okay thanks!
19th Jun 2018, 8:10 AM
1337 H4x0r
1337 H4x0r - avatar
0
I already knew that though , I wanted to call a function when the button is clicked. Any ideas ? what I did: btn.setOnclickListener { functionname()}
19th Jun 2018, 7:16 AM
1337 H4x0r
1337 H4x0r - avatar