Adding a new Menu Option

First of all, confirm that the current Menu looks like this:

Step 02 - 图1

but we want something like this:

Step 02 - 图2

The first thing to do is add in a new resource in strings.xml

  1. <string name="menuReset">Reset</string>

and then the corresponding menu item in donate.xml

  1. <item
  2. android:id="@+id/menuReset"
  3. android:orderInCategory="100"
  4. android:showAsAction="never"
  5. android:title="@string/menuReset"
  6. android:onClick="reset"/>

It’s probably worth removing the ‘Settings’ menu item at this stage too. Next, edit Base.java and add in the following method stub

  1. public void reset(MenuItem item) {}

to ensure our app won’t crash when the menu loads (and looks for a method ‘reset’)

Run the app again and confirm you get the following Menu :

Step 02 - 图3

We can’t implement this menu option fully yet, so for the moment, we’ll just ‘reset’ the target amount back to zero (0) - Step 03.