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

ahegazy

07/27/2018, 11:33 AM
For me 2️⃣ has an advantage because of the
OnClick
annotation and also the ability to use it in any class like a
ViewHolder
for example
a

arekolek

07/27/2018, 11:39 AM
with 1️⃣ onclick is as simple as:
Copy code
someButton.setOnClickListener {
    // do stuff
}
so arguably even easier than 2️⃣ ?
a

ahegazy

07/27/2018, 11:48 AM
Separate method is better choice for me to not create a clutter on the
onCreate
method
Copy code
@OnClick(R.id.some_button) fun onSomeButtonClicked() {
   // do something
}
but more importantly having the ability to use it in any class like a
ViewHolder
is a huge advantage for me
👍 1
2 Views