DayPickerDemo

DayPickerDemo demonstrates how to use the DatePicker and UnitPicker LWUIT components.

Design

The MIDlet starts with a list of several DatePicker implementations such as:

  • Grid view date picker (Day)

  • Three columns date picker (Day, Month, and Year)

  • Two columns date picker (Month and Year)

and the UnitPicker.

The MIDlet can be used in both portrait and landscape modes, and is tested on Nokia Asha SDK 1.0.

Implementation

Initialising LWUIT Display:

Display.init(this); // Initialising LWUIT Display

Initialising different variants of DatePicker and UnitPicker and registering the listeners:

// Creating an instance of DatePicker
dp = new DatePicker("Select a day for auto-updation of your phone software.", DatePicker.TYPE_PICKER_DAY);

// Registering a listener for listening to the DatePicker events
dp.setDatePickerListener(this);

dp2 = new DatePicker("Date Picker (3 column)", DatePicker.TYPE_PICKER_MM_DD_YYYY);
dp2.setDatePickerListener(this);

dp3 = new DatePicker("Date Picker (2 column)", DatePicker.TYPE_PICKER_MM_YYYY);
dp3.setDatePickerListener(this);

dp4 = new DatePicker(DatePicker.TYPE_PICKER_MM_DD_YYYY, 2013, 10);
dp4.setDatePickerListener(this);

up = new UnitPicker("Data limit", "Limit", unit);
up.setUnitPickerListener(this);

Getting DatePicker and UnitPicker object:

public void notifyDatePickerListener(DatePicker datepicker) {
    if (dp.equals(datepicker)) {
        formItem.setItemValueText(dp.getValue() + " of every month");
    }
    if (dp2.equals(datepicker)) {
        fi2.setItemValueText(dp2.getValue());
    }
    if (dp3.equals(datepicker)) {
        fi3.setItemValueText(dp3.getValue());
    }
    if (dp4.equals(datepicker)) {
        fi5.setItemValueText(dp4.getValue());
    }
}

public void notifyUnitPickerListener(UnitPicker unitPicker) {
    if (unitPicker.equals(up)) {
        if (up.isUnitPickerOn()) {
            fi4.setItemValueText("On");
        } else {
            fi4.setItemValueText("Off");
        }
    }
    form.show();
}

Last updated 24 June 2013

Back to top

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×