Bom o meu menu não está abrindo na tela de lista de alunos, eu não estou conseguindo achar o erro, estou dando inflate corretamente mas não aparece, segue as minhas classes:
Manifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="cadastro.caelum.com.br.cadastrocaelum">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<activity android:name="cadastro.caelum.com.br.cadastrocaelum.ListaAlunosActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="cadastro.caelum.com.br.cadastrocaelum.FomularioActivity"></activity>
</application>
</manifest>
menu_principal.xml:
<?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">
<item
android:id="@+id/menu_novo"
android:icon="@drawable/ic_novo"
android:title="Novo"
android:showAsAction="always" />
<item
android:id="@+id/menu_mapa"
android:icon="@drawable/ic_mapa"
android:title="Mapa"
android:showAsAction="always"/>
<item
android:id="@+id/menu_opcoes"
android:icon="@drawable/ic_opcoes"
android:title="Mais opções"
android:showAsAction="always">
<menu>
<item
android:id="@+id/menu_enviar_alunos"
android:icon="@drawable/ic_enviar"
android:title="Sincronizar"
android:showAsAction="always"/>
<item
android:id="@+id/menu_receber_alunos"
android:icon="@drawable/ic_receber"
android:title="Baixar Provas"
android:showAsAction="always"/>
<item
android:id="@+id/menu_preferencias"
android:icon="@drawable/ic_preferencias"
android:title="Preferências"
android:showAsAction="always"/>
</menu>
</item>
</menu>
ListaAlunosActivity.class:
public class ListaAlunosActivity extends Activity {
private ListView listaAlunos;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.listagem_alunos);
String[] alunos = {"Anderson", "Filipe", "Guilherme"};
listaAlunos = (ListView) findViewById(R.id.listagem_ListView);
final ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, alunos);
listaAlunos.setAdapter(adapter);
listaAlunos.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Toast.makeText(ListaAlunosActivity.this, "Posição seleciona: " + position, Toast.LENGTH_LONG).show();
}
});
listaAlunos.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
Toast.makeText(ListaAlunosActivity.this, "Nome do aluno: " + parent.getItemAtPosition(position), Toast.LENGTH_LONG).show();
return true;
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_principal,menu);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
return super.onOptionsItemSelected(item);
}
}