Hi everyone,

I was able to get this to work.

                        Set cOptionSet;
                        Integer iSortOrder = null;
                        Iterator cOptionIterator;
                        TreeMap<Integer, Map<String, String>> tmSortOptions = 
new
TreeMap<Integer, Map<String, String>>();
                ArrayList<HashMap<String, String>> alData = new
ArrayList<HashMap<String, String>>();

                        ltcHmOptions = (HashMap)cObject;
                        cOptionSet = ltcHmOptions.entrySet();
                        cOptionIterator = cOptionSet.iterator();

                        while(cOptionIterator.hasNext() == true) {
                                Map.Entry<String, LTCHashMap> cEntry;
                                String sKey, sValue;
                                HashMap hmOption;

                                cEntry = (Entry<String, LTCHashMap>) 
cOptionIterator.next();
                                sKey = cEntry.getKey();
                                hmOption = cEntry.getValue();

                                // See if the option is available, if so add it 
to our
                                // Tree Map to be sorted.
                                sValue = (String) 
hmOption.get("optionavailable");
                                if(sValue.equals("0") == true) {
                                        // This option is not available to
                                        // continue on to the next.
                                        continue;
                                }

                                // Get the sort order and add to the
                                // Tree Map
                                sValue = (String) hmOption.get("sortoptions");
                                iSortOrder = new Integer(sValue);

                                // Get the display name
                                sValue = (String)hmOption.get("displayvalue");
                                HashMap<String, String> hm = new 
HashMap<String, String>();
                                hm.put("displayvalue", sValue);
                                hm.put("normalvalue", sKey);
                                alData.add(hm);
                                tmSortOptions.put(iSortOrder, hm);
                        }

                        final String[] from = new String[] {"displayvalue", 
"normalvalue"};
                        final int[] to = new int[]{android.R.id.text1};

                SimpleAdapter cAdapter = new SimpleAdapter(m_cContext,
alData, android.R.layout.simple_spinner_item, from, to);
        
cAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
                LTCSimpleAdapterViewBinder cViewBinder = new
LTCSimpleAdapterViewBinder();
                cAdapter.setViewBinder(cViewBinder);
                        // Put the now filled adapter into the control.
                        setAdapter(cAdapter);
On Sep 23, 8:56 pm, gageller <[email protected]> wrote:
> Hi All,
>
> I'm not sure if I'm going in the right direction or not.
>
> I want to create a spinner that contains State names like Alabama,
> California, etc. I need to associate the state codes with the names in
> the spinner e.g. Alabama = AL, California = CA. I do not want to
> display the state code.
>
> When the user selects a State in the spinner, in the onItemSelected
> event I want to be able to retrieve the state code associated with the
> user's selection.
>
> I need to do this with a five or six different spinners where I
> display a list of values but need to perform operations based on the
> normalized value associated with the selection.
>
> Is this possible and is using a SimpleAdapter with a ViewBinder the
> way to go?
>
> I appreciate any help I can get.
>
> Thanks everyone,
>
> Greg

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

Reply via email to