Boa noite, meu código está me retornando uma exceção (Fatal Exception). Como posso resolver isso?
package com.omni.agenda;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import android.content.ClipData;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
public class FormularioActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.formulario);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu_formulario, menu);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
switch(item.getItemId()){
case R.id.menu_formulario_ok:
Toast.makeText(FormularioActivity.this, "Salvo", Toast.LENGTH_SHORT).show();
finish();
break;
}
return super.onOptionsItemSelected(item);
}
}
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Nome"
android:id="@+id/formulario_nome"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Endereco"
android:id="@+id/formulario_endereco"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Telefone"
android:id="@+id/formulario_telefone"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Site"
android:id="@+id/formulario_site"/>
<RatingBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:numStars="5"
android:max="10"
android:id="@+id/formulario_nota"/>
</LinearLayout>
</ScrollView >
<menu xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/menu_formulario_ok"
android:title="ok"
android:icon="@drawable/ic_confirmar"
app:showAsAction="always"/>
</menu>
package com.omni.agenda;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
public class ListaAlunosActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_lista_alunos);
String[] alunos = {"Daniel", "Ronaldo", "Jeferson", "Felipe"};
ListView ListaAlunos = (ListView) findViewById(R.id.lista_alunos);
ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, alunos);
ListaAlunos.setAdapter(adapter);
Button novoAluno = (Button) findViewById(R.id.novo_aluno);
novoAluno.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(ListaAlunosActivity.this, FormularioActivity.class);
startActivity(intent);
}
});
}
}
Não sei tem algum erro no código; se alguém encontrar eu agradeço.