Step 03 - Donate Button
Rename the button in the Outline view:
Fix the lint error - and give the button the text ‘Donate!’. If all goes as expected, your xml files should be like this:
<resources>
<string name="action_settings">Settings</string>
<string name="donateSubtitle">Please give generously</string>
<string name="donateButton">Donate</string>
If there is a deviation from the above - retrace your steps (delete the button) until you can match the above.
We can now switch our attention to the Java Activity class Donate:
Insert the following new field into the class:
The class will have to be imported. The class name will always match the name in the Pallette:
We are free to call the variable anything we like. However, in order to keep confusion to a minimum, always call the variable by the same name you used in the Outline view:
In onCreate - we need to initialise this variable:
Log.v("Donate", "got the donate button");
This is the complete activity class:
Finding the log message can be very difficult, unless you set a filter. In the ‘LogCat’ view in eclipse, create a filter like this:
If you then select the filter, we should see our message:
We should check the donate button actually exists before logging our success:
if (donateButton != null)
{
Log.v("Donate", "Really got the donate button");