Android Tutorial: Populating Spinners PDF Print E-mail
Written by dcPages   
Article Index
Android Tutorial: Populating Spinners
Populate Spinner Using String Resource
Populate Spinner using Database Query
Populate Spinner Manually
All Pages

Any good web designed knows how important the <select> element can be. In a touch screen environment, like Android, where users often don't have a full keyboard, like many Android phones, the ability to simply select an item from a pre-determined list is absolutely vital. It's easier for the user to select what they want - rather than have to type it, it protects your databases from junk data and typos by limiting choices to pre-defined, pre-screened responses. The Android OS has a very robust, user friendly and - relatively - programmer friendly way to handle this: the Android Spinner.

Spinners are simple to use, easy to program and just downright good-looking. However, there are several different ways to populate the list of items in an Android Spinner, and - as of the writing of this article - the Android Developer's Website (developer.android.com) only focuses on one of those methods. This article will break down both of the most popular ways to do populate an Android Spinner: with an array contained in your strings.xml file, and from a database query. Then it will also demonstrate how to manually insert items into a spinner array using code. For ease of navigation, I'm placing each of those on a separate page and including links to them so you can go to the page that best fits your needs as a developer.



 
 

Search

Polls

How Many Phone Numbers Should dcRedial Show?