In putExtra I get the following error cannot be referenced by a static context
and I do not understand why, I just want to pass the data to the 2nd screen
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final EditText dato1 = (EditText) findViewById(R.id.editText);
final EditText dato2 = (EditText) findViewById(R.id.editText2);
final Button boton_enviar = (Button) findViewById(R.id.boton);
final RadioButton rb1 = (RadioButton) findViewById(R.id.checkBox);
final RadioButton rb2 = (RadioButton) findViewById(R.id.checkBox2);
final RadioButton rb3 = (RadioButton) findViewById(R.id.checkBox3);
final RadioButton rb4 = (RadioButton) findViewById(R.id.checkBox4);
boton_enviar.setOnClickListener(new View.OnClickListener() {
String v1 = dato1.getText().toString();
String v2 = dato2.getText().toString();
int operador1 = Integer.parseInt(v1);
int operador2 = Integer.parseInt(v2);
final int suma = operador1 + operador2;
final double resta = operador1 - operador2;
final double multiplicacion = operador1 * operador2;
final double division = operador1 / operador2;
public void onClick(View v) {
switch(v.getId()) {
case R.id.boton:
Intent intent = new Intent(MainActivity.this,Main2Activity.class);
Intent.putExtra("suma",suma);
if (rb1.isSelected()) {
} else if (rb2.isChecked()) {
} else if (rb3.isChecked()) {
} else if (rb4.isChecked()) {
}
startActivity(intent);
}
}
});
}
}