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

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

c# - Better 64-bit byte array hash -

python - PyCharm Type error Message -