title: Changing onclicklistener for a button from radio buttons
body: <p>Hi im trying to make 3 radio buttons change onclick listener for a button each radiobutton sets its own on click listener for that button.
  but i get 
  (MainActivity is not an enclosing class)</p>
  
  <p>Note: the radiobuttons are in settings activity and the button is in mainactivity.</p>
  
  <p><strong>Settings</strong></p>
  
  <pre><code>public class Settings extends MainActivity {
  
  private RadioGroup radioGroup;
  private RadioButton radioButtonpc;
  private RadioButton radioButtonps;
  private RadioButton radioButtonxb;
  public Button settings;
  public Button cheatsactivity;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.settings);
  
      cheatsactivity = (Button) findViewById(R.id.cheats_activity);
      settings = (Button) findViewById(R.id.setting_btn);
      radioGroup = (RadioGroup) findViewById(R.id.RadioGroup);
      radioButtonpc = (RadioButton) findViewById(R.id.radioButton1);
      radioButtonxb = (RadioButton) findViewById(R.id.radioButton2);
      radioButtonps = (RadioButton) findViewById(R.id.radioButton3);
  
      radioButtonpc.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              cheatsactivity.setOnClickListener(new View.OnClickListener() {
                  @Override
                  public void onClick(View v) {
                      Intent intent = new Intent(MainActivity.this, PC.class);
                      startActivity(intent);
                  }
              });
          }
      });
  
      radioButtonxb.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              cheatsactivity.setOnClickListener(new View.OnClickListener() {
                  @Override
                  public void onClick(View v) {
                      Intent intent = new Intent(MainActivity.this, XBOX.class);
                      startActivity(intent);
                  }
              });
          }
      });
      radioButtonps.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              cheatsactivity.setOnClickListener(new View.OnClickListener() {
                  @Override
                  public void onClick(View v) {
                      Intent intent = new Intent(MainActivity.this, PS.class);
                      startActivity(intent);
                  }
              });
          }
      });
  }
  
  
  
  
  }
  </code></pre>
  
  <p><strong>Update</strong>
  It now gives me 
  <code>java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Button.setOnClickListener(android.view.View$OnClickListener)' on a null object reference whenever i clicked on the radio button
  </code>
  Im trying to change to make the user change the onclick listener for a button in main activty from the settings activity any solution?</p>