android - OnClick in fragment without creating tons of onclicklisteners -


how can handle onclick method in fragment without making ton of onclick listeners each button , having huge switch statement them. example, have 10 checkboxes in layout , want fragment handle them in same way (have same onclick)

its pretty easy. if want handle them same way;

        view.onclicklistener listener = new view.onclicklistener()         {             @override             public void onclick(view v)             {                 toast.maketext(mainactivity.this,"asdasd",toast.length_short).show();             }         };         item1.setonclicklistener(listener);         item2.setonclicklistener(listener);         item3.setonclicklistener(listener); 

Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -