Quando o clico em salvar o app encerra.
package br.com.viktorrocha.agendanova.ui.activity;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import br.com.viktorrocha.agendanova.R;
import br.com.viktorrocha.agendanova.dao.AlunoDAO;
import br.com.viktorrocha.agendanova.model.Aluno;
public class FormularioAlunoActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_formulario_aluno);
setTitle("Lista de Alunos");
final AlunoDAO dao = new AlunoDAO();
final EditText campoNome = findViewById(R.id.activity_formulario_aluno_nome);
final EditText campoTelefone = findViewById(R.id.activity_formulario_aluno_telefone);
final EditText campoEmail = findViewById(R.id.activity_formulario_aluno_email);
Button botaoSalvar = findViewById(R.id.activity_formulario_aluno_botao_salvar);
botaoSalvar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String nome = campoNome.getText().toString();
String telefone = campoTelefone.getText().toString();
String email = campoEmail.getText().toString();
Aluno alunoCriado = new Aluno(nome, telefone, email);
dao.salva(alunoCriado);
finish();
}
});
}
}