Welcome back, everyone. Okay.
We're going to use the vector drawables in our menu.
Right click the menu folder,
and choose new, menu resource file.
We want to add three menu items to the report
then set their attributes.
The first one will have the ID, menu_report,
and click okay.
We want to add three menu items to the report,
then set their attributes. The
first one will have the ID
rm_filter
_period.
Create a new string resource for the title using the symbol.
The resource name will be rm_title
_filter_day,
with the resource value, show day.
This menu is going to toggle between showing a single day
or showing the data for a week.
We'll be changing the icon and text in our code,
but it does mean we needed two text strings here.
Rather than opening up the strings.xml file,
I'll just repeat the process and create another resource.
Click the symbol again,
add a new resource.
The resource name will be rm_title
_filter_week.
And the resource value will be show week.
Use the symbol next to icon
to choose ic_filter_7_black
from the drawables.
The showAsAction attribute
should be set to ifRoom.
Okay, the second item.
We'll have the ID rm_filter_date.
The title
will be
rm_title_filter
_date,
and the value will be set report date.
The icon
will be ic_date_range
_black_24dp,
and the showAsAction again will be ifRoom.
Our third item
will be rm_delete.
It'll have a string resource
of rm_title
_delete with the value delete
old timings.
Its icon
will be ic_delete_black_24dp.
And for this button, the showAsAction
will be CollapseActionView.
We could use ifRoom for this one as well,
but this option probably won't be used very often.
For that reason, I don't want it to always appear on the toolbar.
There won't be room in portrait in any case.
So I'll keep it hidden behind the settings menu icon
when in landscape as well.
This setting does a bit more than that.
If there is room to display the item,
it will always appear with its text
even if we specified an icon as we have here.
That means the text will be visible on very large screens.
I think that's a good thing for something destructive like this.
It means the users are less likely to click it to see what it does.
We'll be providing a cancel option, and we'll also ask for confirmation,
but it's still a good idea to keep users away from this option
until they know definitely that they want to use it.
So that's the menu finished. In the next video,
we'll write the code to display the menu and respond to the user tapping it.
See you then.