Olá Vânia!
Me recordo do termo empty, mas não lembro se criei as activities como tal. Seguem abaixo 4 códigos referente ao formulário:
ANDROID MANIFEST.XML
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="br.com.alura.agenda">
<application
android:debuggable="true"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:label="@string/app_name">
<activity
android:name=".ListaAlunosActivity"
android:theme="@style/AppTheme.NoActionBar"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".FormularioActivity"
android:theme="@style/AppTheme.NoActionBar"
android:label="@string/title_activity_formulario">
</activity>
</application>
</manifest>
CONTENT_FORMULARIO.XML
<?xml version="1.0" encoding="utf-8"?>
<!--Tag ScrollView serve para exibir a barra de rolagem quando necessário-->
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!--Tag LinearLayout é i Layout da aplicação -->
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText android:hint="Nome"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/formulario_nome"/>
<EditText android:hint="Endereco"
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"/>
<!-- <Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Salvar"
android:id="@+id/formulario_salvar"/> -->
</LinearLayout>
</ScrollView>
MENU_FORMULARIO.XML
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/menu_formulario_ok"
android:title="Ok"
android:icon="@drawable/ic_confirmar"
app:showAsAction="always"/>
</menu>
FORMULARIOACTIVITY.JAVA
package br.com.alura.agenda;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
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 {
// Os campos do formulário são definidos no XML content_formulario.xml
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.content_formulario);
// Criando o comportamento do Botão Salvar com findViewById buscando o android:id="@+id/formulario_salvar" no content_formulario.xml
// Button botaoSalvar = (Button) findViewById(R.id.formulario_salvar);
// Listener é como se fosse um ouvinte de quando está ocorrendo o click no botão.
// A classe anonima View gera automaticamente o metodo public void onClick(View v){
// botaoSalvar.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// Geração de Mensagem Rápida através da classe Toast, passando a classe Activity, a mensagem e o tempo de exibição LENGTH_SHORT.
// Toast.makeText(FormularioActivity.this, "Aluno Salvo!", Toast.LENGTH_SHORT).show();
// finish();
// }
// });
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu_formulario, menu);
return super.onCreateOptionsMenu(menu);
}
// Método do menu salvar na parte superior do Formulário de inclusão de alunos.
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()){
case R.id.menu_formulario_ok:
Toast.makeText(FormularioActivity.this, "Aluno Salvo!", Toast.LENGTH_SHORT).show();
finish();
break;
}
return super.onOptionsItemSelected(item);
}
}