https://kotlinlang.org logo
#android
Title
# android
h

Heart D

04/05/2019, 12:20 PM
Hello guys am designing an app that uses buttons to call different people. but am failing on setting onclicklistener for all the buttons to work. i can set the onclicklistener for only on button but for many i dont know how to do it. am new in kotlin android
stackoverflow 11
n

natansalda

04/05/2019, 1:18 PM
you can just give id for your buttons in xml and then call every one like that
Copy code
button1.setOnClickListener {
            doSomething()
        }
button2.setOnClickListener {
            doSomething()
        }
p

Pieter

04/05/2019, 1:20 PM
Or Give ids and use the same onclicklistener and check the id of the view coming into the on click