title: How to declare common Listener for buttons click event?
body: <p>In android app coded for common method for all buttons click event, here is the code,</p>
  
  <pre><code>public void onCreate(Bundle  savedInstanceState){
          super.onCreate(savedInstanceState);
          setContentView(R.layout.filter);
          btnOne = (Button)findViewById(R.id.btnone);
          btnTwo = (Button)findViewById(R.id.btntwo);
          btnThree = (Button)findViewById(R.id.btnthree);
          btnFour = (Button)findViewById(R.id.btnfour);
          btnFive = (Button)findViewById(R.id.btnfive);
          btnSix = (Button)findViewById(R.id.btnsix);
          btnSeven = (Button)findViewById(R.id.btnseven);
          btnEight = (Button)findViewById(R.id.btneight);
          btnNine = (Button)findViewById(R.id.btnnine);
          btnTen = (Button)findViewById(R.id.btnten);
  
      OnClickListener listener = new OnClickListener()
      {
  
          public void onClick(View v) {
              // TODO Auto-generated method stub
              doAction(v);
          }
  
      };
  
  }
  
  public void doAction(View v)
      {
          Object tagObject = v.getTag();
          int tag = (Integer) v.getTag();
          String val = (String) d.get(tag);
          if(val.equals("off"))
          {
              //select(tagObject);
              //d.put(tag, "on");
  
          Toast.makeText(getBaseContext(), "Button"+tag+"select", Toast.LENGTH_LONG).show();
      }
      else if(val.equals("on"))
      {
          //unSelect(tagObject);
          //d.put(tag, "off");
          Toast.makeText(getBaseContext(), "Button"+tag+"unselect", Toast.LENGTH_LONG).show();
      }   
  }
  </code></pre>
  
  <p>This code is not working for me. Please give any idea....... Thanks in advance</p>