I have more of a design question than a specific question about a piece of
code.

In my application, the user has to select the correct units from a spinner
for data that he or she inputs into some text boxes. By units, I mean
length (feet, meters, etc), mass (grams, slugs, etc.),  temperature
(degrees C, degrees F, etc), pressure (milibars, pascals, etc), and others.

Requirements:
1. Select in Preferences either SI or English or both
2. Allow users to enter use the most convenient units for each piece of
data (e.g. mass - grams and length inches).
3. Since the app uses this data in calculations, I have to convert the
various quantities into similar units to perform the calculations.
4. Save input data in local db for off-line calculations. I want to store
the values in the original units to avoid any rounding errors by converting
from one set of units to another.
3. Allow for localization of all strings

I initially thought to just put arrays in strings.xml for the various units
(length, mass, temperature, etc) to simplify the code and translations.
However, I end up with a lot of string testing to see which unit was
selected. The string testing is harder to work with when the strings are
translated. I would rather have an index assigned to each unit, then create
a simple two-dimensional array for unit conversions.

I thought of creating a singleton class for each unit, and put all the
conversion data, unit names, abbreviations, etc in there, and then pass
that to the ArrayAdapter for the spinner. But I then loose the convenience
of localizations of string in strings.xml as well as the automatic choice
of the correct localized strings provided by the platform.

Is there a better way to keep using the localization functions provided by
the android platform, and also add some "intelligence" to the string values
returned by the selected item in the spinner?

Thanks!

Mark

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to