Step 06 - NumberPicker

This is our reference documentation:

which is a little overwhelming. Back in the guides:

we might find some useful tutorial type introduction to this control - under ‘User Interface’ - ‘Input Controls’

.. and this is the page on ‘pickers’

This documentation is concerned with Fragments - a concept that may be difficult to grasp initially, and also explores the usage of date and time pickers.

We can get up and running without this much fuss. Returning to the documentation, these three methods should be sufficient initially:

In onCreate, initialise the values:

  1. amountPicker.setMinValue(0);
  2. amountPicker.setMaxValue(1000);

And in donateButtonPressed:

  1. public void donateButtonPressed (View view)
  2. {
  3. int amount = amountPicker.getValue();
  4. Log.v("Donate", "Donate Pressed! with amount " + amount);
  5. }

Run this now - and verify that it operates as expected (see the actual amounts in the log file).