1

How can I display a particular array of items from a database (SQLServer) in a Spinner of Android?

2 Answers 2

7

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!

Sign up to request clarification or add additional context in comments.

1 Comment

i get the data from Microsoft SQL Sever -as in an external database by using websevicess.here my my problem is i don't konw how to add that data to spinner.
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.