This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Android and the fly likes how to use spinners with xml file? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Mobile » Android
Bookmark "how to use spinners with xml file?" Watch "how to use spinners with xml file?" New topic

how to use spinners with xml file?

Karen Wilson
Ranch Hand

Joined: Nov 19, 2012
Posts: 68
I have an app that displays contents of an xml file that is stored on a server. The xml file contains a list of events and these events have categories. I want to be able to select which category I want then only display the events for that category. So I created a new xml with a spinner but I have no idea what I need to change in the code so for example if I select the film category only the film events are displayed. I know i will also need to change the events xml file.

here is some of the xml file:

and here is main java class that displays the xml file from the server:
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 41591
After the download and XML parsing, a "loadTourPackages" method is called - I think that should be "displayTourPackages", so that the display gets updated, no? You may need to invalidate the layout so that the UI gets updated.

Ping & DNS - my free Android networking tools app
Irina Goble
Ranch Hand

Joined: May 09, 2004
Posts: 91
You could use SQLite with a SimpleCursorAdapter or write your own Adapter that will filter by chosen category or, maybe, ask the server for events of that particular category only. Is the question about how to filter events?

You are already using an AsyncTask, there is no need for a Handler. AsyncTask.onPostExecute() can do whatever the Handler must do.
Don't get me started about those stupid light bulbs.
subject: how to use spinners with xml file?