You probably want to take one of the following approaches... Note that my code is overly-simplified, I did not verify that it doesn't contain compile errors (I just typed it up real quick in this email), and you will have to customize it to suit your needs:
*Method 1:* public class MyActivity extends Activity { private Button m_btn1; private Button m_btn2; public void onCreate(Bundle bundle) { super.onCreate(bundle) //Set the click listener for the first button m_btn1 = findViewById(R.id.first_button_id); m_btn1.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { //Do stuff for the click of m_btn1 } }); //Set the click listener for the second button m_btn2 = findViewById(R.id.second_button_id); m_btn2.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { //Do stuff for the click of m_btn2 } }); } } *Method 2:* public class MyActivity extends Activity implements View.OnClickListener { private Button m_btn1; private Button m_btn2; public void onCreate(Bundle bundle) { super.onCreate(bundle) //Set the click listener for the first button m_btn1 = findViewById(R.id.first_button_id); m_btn1.setOnClickListener(this); //Set the click listener for the second button m_btn2 = findViewById(R.id.second_button_id); m_btn2.setOnClickListener(this); } public void onClick(View v) { if (v == m_btn1) { //Do stuff for the click of m_btn1 } else if (v == m_btn2) { //Do stuff for the click of m_btn2 } } } Hope that helps clear up some things.... Thanks, Justin Anderson MagouyaWare Developer http://sites.google.com/site/magouyaware On Wed, Jun 20, 2012 at 1:28 PM, Justin Anderson <magouyaw...@gmail.com>wrote: > Sorry Lars... my post was overly harsh. As mentioned before, the > assumption is that you already have a reasonable amount of programming > experience. > > I will post the correct way to do what you are after in just a little > bit... > > > Thanks, > Justin Anderson > MagouyaWare Developer > http://sites.google.com/site/magouyaware > > > On Wed, Jun 20, 2012 at 1:16 PM, Lars <lars.breum...@gmail.com> wrote: > >> Thank you I really appreciate you post=) I just misunderstood the point >> of this forum. You know any beginner forums?(english or danish). >> >> Den onsdag den 20. juni 2012 21.08.36 UTC+2 skrev Nobu Games: >> >>> Hey Lars, good to see that you want to learn programming at your young >>> age and picked Android for doing your first few steps. It's a great choice >>> for that, in my opinion. >>> >>> But you need to understand that this forum is not meant to answer >>> beginner questions. We actually assume that you already know programming >>> and especially Java by your heart. And all your questions here clearly show >>> that you still have quite some way to go. >>> >>> You should try and find a beginners level Java forum where people are >>> glad to help you out with your questions. >>> >>> But anyway, keep up your spirit. I think playing around with existing >>> code samples is the way to go. >>> >>> >>> On Wednesday, June 20, 2012 1:53:26 PM UTC-5, Lars wrote: >>>> >>>> Eclipse (of some reason) tells me to type them, or i will get errors. >>>> I'm very new at making apps(+ I do this in my free time I'am fifteen >>>> years old). >>>> All do is: I read in my book trying to type in eclipse, and then i try >>>> to get help from here. >>>> >>> -- >> You received this message because you are subscribed to the Google >> Groups "Android Developers" group. >> To post to this group, send email to android-developers@googlegroups.com >> To unsubscribe from this group, send email to >> android-developers+unsubscr...@googlegroups.com >> For more options, visit this group at >> http://groups.google.com/group/android-developers?hl=en >> > > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en