O android reconheceu o meu icone mapa no canto esquerdo da tela xml, mas ele não está aparecendo na aplicaçao. O que aparece são os 3 pontinhos padrão do menu android.
<?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="br.com.rodrigo.agendinha.ListaAlunosActivity">
<item
android:id="@+id/menu_enviar_notas"
android:title="Enviar notas"
android:icon="@mipmap/ic_enviar"
app:showAsAction="always" />
<item
android:id="@+id/menu_baixar_provas"
android:title="Baixar provas"
android:icon="@mipmap/ic_download"
app:showAsAction="always"/>
<item
android:id="@+id/menu_mapa"
android:title="Visualizar mapa"
android:icon="@mipmap/ic_mapa1"
android:showAsAction="always"/>
</menu>
//Lista AlunosActivity
package br.com.rodrigo.agendinha;
import android.Manifest;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.provider.Browser;
import android.support.annotation.NonNull;
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.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.Toast;
import java.util.List;
import br.com.rodrigo.agendinha.adapter.AlunosAdapter;
import br.com.rodrigo.agendinha.converter.AlunoConverter;
import br.com.rodrigo.agendinha.dao.AlunoDAO;
import br.com.rodrigo.agendinha.modelo.Aluno;
public class ListaAlunosActivity extends AppCompatActivity {
private ListView listaAlunos;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_lista_alunos);
listaAlunos = (ListView) findViewById(R.id.lista_alunos);
listaAlunos.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> lista, View item, int i, long l) {
Aluno aluno = (Aluno) listaAlunos.getItemAtPosition(i);
Intent intentVaiProFormulario = new Intent(ListaAlunosActivity.this, FormularioActivity.class);
intentVaiProFormulario.putExtra("aluno", aluno);
startActivity(intentVaiProFormulario);
}
});
Button novoAluno = (Button) findViewById(R.id.novo_aluno);
novoAluno.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intentVaiProFormulario = new Intent(ListaAlunosActivity.this, FormularioActivity.class);
startActivity(intentVaiProFormulario);
}
});
registerForContextMenu(listaAlunos);
}
private void carregaLista() {
AlunoDAO dao = new AlunoDAO(this);
List<Aluno> alunos = dao.buscaAlunos();
dao.close();
AlunosAdapter adapter = new AlunosAdapter(this, alunos);
listaAlunos.setAdapter(adapter);
}
@Override
protected void onResume() {
super.onResume();
carregaLista();
}
@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:
new EnviaAlunosTask(this).execute();
break;
case R.id.menu_baixar_provas:
Intent vaiParaProvas = new Intent(this, ProvasActivity.class);
startActivity(vaiParaProvas);
break;
case R.id.menu_mapa:
Intent vaiParaMapa = new Intent(this, MapsActivity.class);
startActivity(vaiParaMapa);
break;
}
return super.onOptionsItemSelected(item);
}
@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 menuItem) {
if (ActivityCompat.checkSelfPermission(ListaAlunosActivity.this, Manifest.permission.CALL_PHONE)
!= PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(ListaAlunosActivity.this,
new String[]{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 menuItem) {
AlunoDAO dao = new AlunoDAO(ListaAlunosActivity.this);
dao.deleta(aluno);
dao.close();
carregaLista();
return false;
}
});
}
}