Populating Spinner from XML

General topics about the Android-Platform itself.
Coding issues please to the subforum right below.

Populating Spinner from XML

Postby bolo » Thu Jun 18, 2009 10:53 am

Can anyone tell me how to populate a spinner control from a custom XML file?

What I'm trying to do is display a list of cities derived from the XML, which contains city name/lat & long values. And when selected will allow me to determine the lat & long for selected city.

Thanks
bolo
Freshman
Freshman
 
Posts: 9
Joined: Wed Jun 17, 2009 5:23 pm

Top

Postby WarrenFaith » Fri Jun 19, 2009 8:39 am

Sorry but i don't really understand what you want to do...
Can you be a bit more specific?
WarrenFaith
Moderator
Moderator
 
Posts: 227
Joined: Fri Mar 13, 2009 10:59 am
Location: Berlin, Germany

Postby bolo » Fri Jun 19, 2009 8:49 am

WarrenFaith wrote:Sorry but i don't really understand what you want to do...
Can you be a bit more specific?


Hi - I understand you can easily use an ArrayAdapter to bind to a Spinner, but they only (as far as I can see) support a one dimensional array. What I was trying to discover was whether theres any existing adapter that supports custom XML files..

E.g.
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <data>
  2.  <city>
  3.    <name>London</name>
  4.    <latitude>52.0</latitude>
  5.    <longitude>0</longitude>
  6.   </city>
  7.  <city>
  8.    <name>Sydney, Australia</name>
  9.    <latitude>32.0</latitude>
  10.    <longitude>120</longitude>
  11.   </city>
  12. </data>
Parsed in 0.002 seconds, using GeSHi 1.0.8.4


And show the city name in the spinner, but be able to retrieve the other xml data, lat & long when the item is selected....
bolo
Freshman
Freshman
 
Posts: 9
Joined: Wed Jun 17, 2009 5:23 pm

Postby WarrenFaith » Fri Jun 19, 2009 9:28 am

Take a look at this, it may help you:
viewtopic.php?t=353
WarrenFaith
Moderator
Moderator
 
Posts: 227
Joined: Fri Mar 13, 2009 10:59 am
Location: Berlin, Germany

Top

Return to General

Who is online

Users browsing this forum: No registered users and 1 guest