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

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -