Check this article: http://www.androidcompetencycenter.com/tag/android-basics/ This does what you want to do.
On May 19, 10:39 am, GMaker0507 <[email protected]> wrote: > In my app, i have around 4 different layouts, and on them i have a > total of like 10 different buttons, and maybe more to come in the > future > > I want them to all have the same onclicklistener, which is a single > instance class i created, that would basically do whatever was needed > depenindg on the id of the item, via a switch statement. > > So my question is, is there a easy way to give all the items the same > listener through like a for loop or something, or am i gonna have to > > Button b = (Button)this.findViewById(R.id.Whatever); > b.setOnClickListener(thisThing); > > for each button now and in the future --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Beginners" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en -~----------~----~----~----~------~----~------~--~---

