Boa tarde,
Estou tendo problema ao criar o menu lista alunos, quando tento compilar ele apresenta os erros abaixo:
Error:(158, 41) error: cannot find symbol variable menu_lista_alunos Error:(167, 22) error: cannot find symbol variable menu_enviar_notas
Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
Compilation failed; see the compiler error output for details.
segue o código do Menu:
<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=".ListaAlunosActivity">
<item android:id="@+id/menu_enviar_notas"
android:title="Enviar Notas"
android:icon="@drawable/ic_enviar"
app:showAsAction="always" />
</menu>
e o código da classe LIstaAlunoActivity.java
package br.com.espalhaai.agenda;
import android.annotation.TargetApi;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Build;
import android.support.v4.app.ActivityCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.ContextMenu;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.ListView;
import android.widget.Toast;
import java.util.List;
import br.com.espalhaai.agenda.adapter.AlunosAdapter;
import br.com.espalhaai.agenda.dao.AlunoDAO;
import br.com.espalhaai.agenda.modelo.Aluno;
public class ListaAlunoActivity extends AppCompatActivity {
private static final int CODIGO_SMS = 124;
private ListView listaAlunos;
@TargetApi(Build.VERSION_CODES.M)
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_lista_aluno);
listaAlunos = (ListView) findViewById(R.id.lista_alunos);
// permissão para sms
if (checkSelfPermission(android.Manifest.permission.RECEIVE_SMS) != PackageManager.PERMISSION_GRANTED ){
requestPermissions(new String[] {android.Manifest.permission.RECEIVE_SMS}, CODIGO_SMS);
}
listaAlunos.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> lista, View item, int position, long id) {
Aluno aluno = (Aluno) listaAlunos.getItemAtPosition(position);
Intent intentVaiParaFormulario = new Intent(ListaAlunoActivity.this, FormularioActivity.class);
intentVaiParaFormulario.putExtra("aluno",aluno);
startActivity(intentVaiParaFormulario);
}
});
/*
listaAlunos.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
Toast.makeText(ListaAlunoActivity.this, "CLIQUE LONGO", Toast.LENGTH_SHORT).show();
return false;
}
});
*/
Button novoAluno = (Button) findViewById(R.id.lista_aluno_novo);
novoAluno.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intentVaiProFormulario = new Intent(ListaAlunoActivity.this, FormularioActivity.class);
startActivity(intentVaiProFormulario);
}
});
registerForContextMenu(listaAlunos );
}
private void carregaLista() {
AlunoDAO dao = new AlunoDAO(this);
List<Aluno> alunos = dao.buscaAlunos();
dao.close();
//ArrayAdapter<Aluno> adapter = new ArrayAdapter<Aluno>(this, android.R.layout.simple_list_item_1, alunos);
//listaAlunos.setAdapter(adapter);
AlunosAdapter adapter = new AlunosAdapter(this, alunos);
listaAlunos.setAdapter(adapter);
}
@Override
protected void onResume() {
super.onResume();
carregaLista();
}
@Override
public void onCreateContextMenu(ContextMenu menu, View v, final ContextMenu.ContextMenuInfo menuInfo) {
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
final Aluno aluno = (Aluno) listaAlunos.getItemAtPosition(info.position);
MenuItem itemligar = menu.add("Ligar");
itemligar.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
if (ActivityCompat.checkSelfPermission(ListaAlunoActivity.this, android.Manifest.permission.CALL_PHONE)
!= PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(ListaAlunoActivity.this, new String[]{android.Manifest.permission.CALL_PHONE}, 123);
}
else {
Intent intentLigar = new Intent(Intent.ACTION_CALL);
intentLigar.setData(Uri.parse("tel:" + aluno.getTelefone()));
startActivity(intentLigar);
}
return false;
}
});
MenuItem itemSMS = menu.add("Enviar SMS");
Intent intentSMS = new Intent(Intent.ACTION_VIEW);
intentSMS.setData(Uri.parse("sms:" + aluno.getTelefone()));
itemSMS.setIntent(intentSMS);
MenuItem itemMapa = menu.add("Visualizar no mapa");
Intent intentMapa = new Intent(Intent.ACTION_VIEW);
intentMapa.setData(Uri.parse("geo:0,0?q=" + aluno.getEndereco()));
itemMapa.setIntent(intentMapa);
MenuItem itemSite = menu.add("Visitar site");
Intent intentSite = new Intent(Intent.ACTION_VIEW);
String site = aluno.getSite();
if (!site.startsWith("http://")){
site = "http://" + site;
}
intentSite.setData(Uri.parse(site));
itemSite.setIntent(intentSite);
MenuItem deletar = menu.add("Deletar");
deletar.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
AlunoDAO dao = new AlunoDAO(ListaAlunoActivity.this);
dao.deleta(aluno);
dao.close();
carregaLista();
return false;
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_lista_alunos, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()){
case R.id.menu_enviar_notas:
Toast.makeText(this, "Enviando notas...", Toast.LENGTH_SHORT).show();
break;
}
return super.onOptionsItemSelected(item);
}
/*
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (requestCode == 123){
// faz ligação
}else
if (requestCode == 124){
// faz sms
}
} */
}
Desde já agradeço a ajuda. Abs