1
I have the following code:
public boolean onNavigationItemSelected(MenuItem item) {
// Handle navigation view item clicks here.
int id = item.getItemId();
if (id == R.id.nav_camera) {
// Handle the camera action
} else if (id == R.id.nav_gallery) {
} else if (id == R.id.nav_slideshow) {
} else if (id == R.id.nav_manage) {
} else if (id == R.id.nav_share) {
} else if (id == R.id.nav_send) {
builder = new AlertDialog.Builder(atividade);
builder.setTitle("Deseja realmente sair?");
builder.setPositiveButton("Sim", new DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog, int id) {
// User clicked OK button
finish();
}
});
//Toast.makeText(this, "sair",Toast.LENGTH_SHORT).show();
finish();
}
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
return true;
}
In the excerpt: I’d like to ask if you’d really like to leave.
If he says yes the application is finished. And in case he says no the screen is kept.
How do you make it work, but do not want!
There wouldn’t have to be two buttons for him to choose, and you treat the user’s response?
– GabrielLocalhost
Yes...but I did one didn’t work so it won’t work with 2...
– Aline