1
resposta

Unfortunately, Agenda has stopped

Esse erro ocorre sempre após a aula 4. Já refiz o aplicativo do zero e esbarro no mesmo erro, apesar de compilar e abrir no emulador. Seguem os códigos:

ACTIVITY_FORMULARIO

<?xml version="1.0" encoding="utf-8"?>
<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:hint="Nome"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/formulario_nome"/>

        <EditText android:hint="Endereço"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/formulario_endereco"/>

        <EditText android:hint="Telefone"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/formulario_telefone"/>

        <EditText android:hint="Site"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/formulario_site"/>

        <RatingBar
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:numStars="5"
            android:max="10"
            android:layout_gravity="center"
            android:id="@+id/formulario_nota"/>


    </LinearLayout>
</ScrollView>

MENU_FORMULARIO:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    tools:context="aula.agenda.agenda.FormularioActivity">

    <item android:id="@+id/menu_formulario_ok"
        android:title="Ok"
        android:icon="@drawable/ic_confirmar"
        app:showAsAction="always"
         />
</menu>

FORMULARIOACTIVITY

package aula.agenda.agenda;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.Toast;

import aula.agenda.agenda.modelo.Aluno;

public class FormularioActivity extends AppCompatActivity {

    private FormularioHelper helper;
    /**
     * ATTENTION: This was auto-generated to implement the App Indexing API.
     * See https://g.co/AppIndexing/AndroidStudio for more information.
     */
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_formulario);

        helper = new FormularioHelper(this);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.menu_formulario, menu);
        return super.onCreateOptionsMenu(menu);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case R.id.menu_formulario_ok:

                Aluno aluno = helper.pegaAluno();
                Toast.makeText(FormularioActivity.this, "Aluno" + aluno.getNome() + "salvo!", Toast.LENGTH_SHORT).show();

                finish();
                break;
        }

        return super.onOptionsItemSelected(item);
    }

}
1 resposta

Deve estar aparecendo uma exception no log, pde mandar pra gente? E o seu FormularioHelper tambem