Thursday, July 3, 2008

Too many choices

We all know, many Java ME devices impose several restrictions in terms of user interface. The screen are small, the non-Qwerty keyboards are clumsy if you're not a SMS addicted.
It's not hard to figure out: the less you demand user typing, the more successful your mobile application is prone to be.
Well planed LCDUI ChoiceGroups are valuable to keep user away from typing.
When modeling a Data Collector inside a MIDlet I often find at least one big ChoiceGroup with too many elements to display. Indeed it can save user typing, however it poses another problem:the scrolling will be annoying with more than 15 ChoiceGroup elements.
It takes a turn for worse if your ChoiceGroup is huge: While acceptable in emulators at development time, a huge list can break your MIDlet once deployed to a real device. My Sony Ericsson K300i does not tolerate more than 256 ChoiceGroup elements.

Can Diamond Powder address this issue ?
Keep reading...

Everybody is used to fill suggestion boxes in Desktop or Web 2.0 applications. It handles big or huge lists of choices, and restrain it to small lists of choices.
If you have already tried Diamond Powder choicegroups and listmodels (see previous posts), you're exactly one line of schema configuration from building a kind of LCDUI suggestion box.

The too-many-choices sample brings a huge list of gas station brands: there are over 700 elements. It works with diamond-powder-0.3.jar (or newer).
We use the concept of Filter to shrink such a huge list of options. Take a look:

The field brandFilter is your (brand) new friend:

schema.put("field.brandFilter", "filter;brands filter;gasStationBrand;sorted");
  • filter: is the field type (actually it is rendered as a TextField)
  • 'brands filter': is the filter label
  • gasStationBrand: a choicegroup, that´s going to be 'filtered'
  • sorted: a flag telling our filter that the choicegroup elements are alphabetically sorted - it speeds up processing. The other values allowed here are 'unsorted' (the self-explanatory default), and 'initials'. During your experiences, try 'initials', and watch the difference.
The choicegroup gasStationBrand has a never seen before property:

schema.put("field.gasStationBrand", "choicegroup;brand;allBrands;exclusive;true");
  • true: It means that a choicegroup is completely ruled by a filter, from the very beginning - in this case, an empty filter will prevent from showing choicegroup elements (and prevent you MIDlet from crash in real world if your choicegroup is huge). Try 'false' (the default) and watch the difference.
Finally, listmodel allBrands carries too many gas station brands.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.