1
I’m making an application similar to a schedule and need to put a button to open a registered site, I’ve done with a long click on the table and it worked however, on a button I can not use the same syntax
@Override
public void onCreateContextMenu(final ContextMenu menu, View v, final ContextMenu.ContextMenuInfo menuInfo) {
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
final Aluno aluno = (Aluno) listaAlunos.getItemAtPosition(info.position);
MenuItem itemSite = menu.add("Visitar Site");
Intent intentSite = new Intent(Intent.ACTION_VIEW);
String site ="http://www.uol.com.br";
aluno.getSite();
if(!site.startsWith("http://")) {
site = "http://" + site;
}
intentSite.setData(Uri.parse(site));
itemSite.setIntent(intentSite);