title: Why addListenerOnButton method is used in Android?
body: <p>It would be really helpful is someone told me why this method is used. </p>
  
  <pre><code>public void addListenerOnButton() {
  
          toggleButton1 = (ToggleButton) findViewById(R.id.toggleButton1);
          toggleButton2 = (ToggleButton) findViewById(R.id.toggleButton2);
          btnDisplay = (Button) findViewById(R.id.btnDisplay);
  
          btnDisplay.setOnClickListener(new OnClickListener() {
  
              @Override
              public void onClick(View v) {
  
                 StringBuffer result = new StringBuffer();
                 result.append("toggleButton1 : ").append(toggleButton1.getText());
                 result.append("\ntoggleButton2 : ").append(toggleButton2.getText());
  
               Toast.makeText(MyAndroidAppActivity.this, result.toString(),
               Toast.LENGTH_SHORT).show();
  
             }
  }
  </code></pre>