Skip to content

Instantly share code, notes, and snippets.

@luizmarcus
Last active September 3, 2017 18:04
Show Gist options
  • Save luizmarcus/b601065896450aa5c6e855f02d3fad7d to your computer and use it in GitHub Desktop.
Save luizmarcus/b601065896450aa5c6e855f02d3fad7d to your computer and use it in GitHub Desktop.
private void createDrawer(){
//Itens do Drawer
PrimaryDrawerItem item1 = new PrimaryDrawerItem().withIdentifier(1).withName(R.string.menu1);
PrimaryDrawerItem item2 = new PrimaryDrawerItem().withIdentifier(2).withName(R.string.menu2);
PrimaryDrawerItem item3 = new PrimaryDrawerItem().withIdentifier(3).withName(R.string.menu3);
//Definição do Drawer
Drawer drawer = new DrawerBuilder()
.withActivity(this)
.withToolbar(toolbar)
.addDrawerItems(
item1,
new DividerDrawerItem(),//Divisor
item2,
new SectionDrawerItem().withName(R.string.section),//Seção
item3
)
.withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
@Override
public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
textView.setText("Você clicou em: "+ ((Nameable) drawerItem).getName().getText(MainActivity.this));
return false;
}
})
.withSelectedItemByPosition(0)
.build();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment