views:

212

answers:

1

I'm writing an application which has an interval time as a parameter and would like a field similar to the one the Timer has to set its time. Values of a few seconds to a few hours make sense for the application.

What type of field should I use?

+1  A: 

Looks like a custom field.

Your choices with built-in fields are: net.rim.device.api.ui.component.NumericChoiceField, which basically acts like a drop-down with numbers in it (not great when you're talking about 60 minutes/seconds, but if you want to constrain to say 5 minute intervals or something it might be ok).

net.rim.device.api.ui.component.EditField with a custom net.rim.device.api.ui.text.TextFilter (you could use a NumericTextFilter, but that wouldn't constrain you to 0-60, it'd allow any numbers).

Or you can roll you own. See this article for a start on creating custom fields. You'll probably want to override navigationMovement to make the numbers increment/decrement on trackball up & down, and to move the focus within the field while going left & right - setting an internal state variable indicating where the focus is and overriding getFocusRect to return an appropriate focus rectangle (be sure to call focusRemove and focusAdd from within navigationMovement to let the framework know you've updated the focus).

Anthony Rizk
Yeah, my backup plan is an EditField with a NumericTextFilter. This is for an assignment and were told to spend little time on the GUI, so rolling my own custom field is more work than I'd like. Oh well.
Ben S