Quando tento organizar as activitys para chamar o formulario de cadastro de alunos é gerado o erro de : Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.google.android.material.floatingactionbutton.FloatingActionButton.setOnClickListener(android.view.View$OnClickListener)' on a null object reference
package agrotis.one.ui.activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import agrotis.one.DAO.AlunoDAO;
import agrotis.one.R;
import static agrotis.one.R.id.activity_lista_alunos_fab_novo_aluno;
public class ListaAlunosActivity extends AppCompatActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTitle("Lista de Alunos");
FloatingActionButton botaoNovoAluno = findViewById(activity_lista_alunos_fab_novo_aluno);
botaoNovoAluno.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity(new Intent(ListaAlunosActivity.this,
CadastroAlunoActivity.class
));
}
});
setContentView(R.layout.activity_lista_alunos);
AlunoDAO dao = new AlunoDAO();
ListView listaDeAlunos= findViewById(R.id.activity_lista_alunos_list_view);
listaDeAlunos.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_list_item_1,dao.todos()));
}
}