The problem in question is that I want to configure a switch to move from one activity to another.
The thing is that the program compiles normal but at the time of using the switch it tells me that the application stopped.
Current code:
package com.exercisetosuityou.exercisetosuityou;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Switch;
public class Test_entrenamiento extends AppCompatActivity {
Switch switchE;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test_entrenamiento);
switchE=(Switch) findViewById(R.id.switchEntrenamientoencasa);
}
public void Anterior(View view){
Intent anterior=new Intent(this,MainActivity.class);
startActivity(anterior);
}
public void Entrenamientoencasa(View view) {
if(switchE.isChecked()){
Intent entrenamientoencasa=new Intent(this,Entrenamientoencasa.class);
startActivity(entrenamientoencasa);
}
}
}