Boa noite,
Os formulário do meu projeto não estão apresentando a barra de título, com isso, o menu também não está aparecendo. Alguém saberia dizer qual o problema? Seguem, abaixo, os arquivos do projeto envolvidos no exercício:
<!-- AndroidManifest.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:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".ListaAlunosActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".FormularioActivity"
android:label="@string/title_activity_formulario"
android:theme="@style/AppTheme.NoActionBar">
</activity>
</application>
</manifest>
//FormularioActivity
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.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.activity_formulario);
Button btnSalvar = (Button) findViewById(R.id.formulario_salvar);
btnSalvar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast toast = Toast.makeText(FormularioActivity.this, "Alunos salvo com sucesso!", Toast.LENGTH_SHORT);
toast.show();
finish();
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu_formulario, menu);
return true;
}
}
<!-- activity_formulario.xml -->
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".FormularioActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<EditText
android:id="@+id/formulario_nome"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Nome"/>
<EditText
android:id="@+id/formulario_endereco"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Endereço"/>
<EditText
android:id="@+id/formulario_telefone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Telefone"/>
<EditText
android:id="@+id/formulario_site"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Site"/>
<RatingBar
android:id="@+id/formulario_nota"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:numStars="5"
android:max="10"
android:layout_gravity="center"/>
<Button
android:id="@+id/formulario_salvar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="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"
xmlns:tools="http://schemas.android.com/tools"
tools:context="br.com.alura.agenda.FormularioActivity">
<item android:id="@+id/menu_formulario_ok"
android:title="Ok"
android:icon="@drawable/ic_confirmar"
app:showAsAction="always"/>
</menu>
Inicialmente havia um arquivo context_formulario.xml que eu deletei e passei a usar somente o activity_formulario.xml.