Skip to content

Instantly share code, notes, and snippets.

@muhakmal
Created December 23, 2017 13:49
Show Gist options
  • Save muhakmal/b6c5065a565ff0a83a5b81bf3fe203ab to your computer and use it in GitHub Desktop.
Save muhakmal/b6c5065a565ff0a83a5b81bf3fe203ab to your computer and use it in GitHub Desktop.
navigasi drawer item
@Override
public boolean onNavigationItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == R.id.nav_beranda) {
viewPager.setCurrentItem(0);
} else if (id == R.id.nav_info_akun) {
Intent infoAkun = new Intent(MainActivity.this, InfoAkunActivity.class);
startActivity(infoAkun);
} else if (id == R.id.nav_riwayat_order) {
Intent riwayatOrder = new Intent(MainActivity.this, RiwayatOrderActivity.class);
startActivity(riwayatOrder);
} else if (id == R.id.nav_kontak_kami) {
try {
Intent emailIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("mailto:" + "kontak@masakini.xyz"));
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Kontak MasakIni | ");
startActivity(emailIntent);
} catch (ActivityNotFoundException e) {
//nothing
}
}
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
return true;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment