android - Is Using Different Names for onClick methods for Different buttons a good coding style? -


rather using single onclick() method buttons in activity, , using switch statement determine button clicked, set different methods different buttons in android:onclick xml parameter. example, 1 button set onclick parameter onclickcalculatebutton , button set onclick xml parameter onclicknewfilebutton.

is coding practice?

there no real convention in case. i've seen programmers way or other, , i'm guessing people agree.

for buttons not straight forward (not in activity/fragment) , cant used butterknife don't set click listener in xml rather implementing @ specific class (activity/fragment/whatever) switch-case , referring specific method.

switch(view.getid()){

case r.id.button_one:

clickonbuttonone(view);

break; ...

for buttons know lifecycle (in fragment/activity) use butterknife , use annotation (

@onclick(r.id.button)


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -

jdbc - Not able to establish database connection in eclipse -