title: toggle button setOnClickListener can not resolve
body: <p>I am new to android programming and i got this from the developer website on how to properly implement this. However when i copy and pasted this into android studio it could not resolve setOnClickListener, setOnCheckedChangeListener, and buttonView.</p>
  
  <p>This is my first time working with toggle buttons and buttons in android and i did a lot of searching about on here before i broke down to ask this. This is a separate button class outside of MainInterface do i need to extend or implement anything special or import anything?</p>
  
  <pre><code> import android.content.Context;
   import android.net.ConnectivityManager;
   import android.net.NetworkInfo;
   import android.view.View;
   import android.widget.CompoundButton;
   import android.widget.ToggleButton;        
  
   public class Button extends MainInterface {
  
      ToggleButton toggle = (ToggleButton) findViewById(R.id.BeaconButton);
      toggle.setOnClickListener(new CompoundButton.OnCheckedChangeListener());
      toggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
          public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
              if (isChecked) {
                  // The toggle is enabled
              } else {
                  // The toggle is disabled
              }
          }
      });
  }
  </code></pre>
  
  <p>Also what is the difference between the above code and the following code. would the following code be applicable for setting listeners?</p>
  
  <pre><code>public void onToggleClicked(View view) {
      // Is the toggle on?
      boolean on = ((ToggleButton) view).isChecked();
      if (on) {
          // do something
          }
  
      } else {
          // set as it was
      }
  }
  </code></pre>