Going crazy getting the name of an item shown in the drawer.
My approach from existing 2015 and 2016 issues:
IDrawerItem item = drawer.getDrawerItem(drawer.getCurrentSelection());
item.getName() ----- NOT FOUND ANYMORE.
Found out if I use PrimaryDrawerItem .getName() works.
But I have different types of Items in Drawer.
You could add the name as a tag...
@soenkegissel well the IDrawerItem is an interface.
if(item instanceof PrimaryDrawerItem) {
((PrimaryDrawerItem) item).getName();
}
@afarber thanks for answering ;)
Allright - I gave the drawerItem a tag.
IDrawerItem item = drawer.getDrawerItem(drawer.getCurrentSelection());
if(item != null)
Log.d(TAG, "Toolbar subTitle: "+ item.getTag());
This returns "Toolbar subTitle: 2131562033"
Did it like this:
getResources().getString((Integer) item.getTag()) because tag is object filled with R.string in my case.
Thank you very much!
Most helpful comment
@afarber thanks for answering ;)