title: Button array onclicklistener
body: <p>I have set up 10 buttons in xml and added to main activity. I show only 2. All button just change a variable and button colors. Is there a method to group all the button to a single onclicklistener and use switch to check which button was pressed. using separate onclicklistener seems like allot of waisted space.</p>
  
  <pre><code>@Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      f1 =(Button) findViewById(R.id.f1);
      f2 =(Button) findViewById(R.id.f2);
  
      f1.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              clearbutton();
              f1.setBackgroundColor(Color.RED);
              intbtnSelect=0; 
          }
      });
  
      f2.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              clearbutton();
              f2.setBackgroundColor(Color.RED);
              intbtnSelect=1;
          }
      });
  </code></pre>