Reputation: 8487
How can I display a particular array of items from a database (SQLServer) in a Spinner of Android?
Upvotes: 1
Views: 1739
Reputation: 69318
jTDS could be what you are looking for, a 100% pure java JDBC driver for Microsoft SQLServer. Then you can implement an Adapter to retrieve the data.
Upvotes: 0
Reputation: 111595
You provide data to your Spinner
by way of a SpinnerAdapter
. The adapter can be backed by a simple array, or by a database cursor, or whatever you like...
If you really mean Microsoft SQL Server — as in an external database — you would need to have some sort of web-service or other internet-based protocol to let you retrieve the data from the remote server. Then you could bind the data yourself to an ArrayList
or Cursor
.
Alternatively, if you mean local database storage such as an SQLite DB, then it's even easier as you don't need to query over the network.
Essentially you can just follow any ListView
tutorials as the process is pretty much the same — in your case you just want to call Spinner.setAdapter()
rather than ListView.setAdapter()
.
In fact, there is a Spinner
tutorial on the Android developers' site!
Upvotes: 7