Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6328409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:27:13+00:00 2026-05-24T17:27:13+00:00

I query my SQL database to populate my spinners, I have no problem populating

  • 0

I query my SQL database to populate my spinners, I have no problem populating the spinner with a string array of the resulting Book Titles (this is a library style app). While getting the Book Titles into the spinner for selection is no problem, what is the best way to tie these titles back to their SQL _id’s? I’ve been looking for a way to make spinners “multi-dimensional” but so far I don’t see how.

Any help in the right direction would be much appreciated, thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T17:27:14+00:00Added an answer on May 24, 2026 at 5:27 pm

    You definitely want the SimpleCursorAdapter. You must include the _id in the select query. Here is an example…

    Spinner spinner = (Spinner) dialog.findViewById(R.id.mm_spinner);
    
    // DatabaseInterface would be your data access class...
    DatabaseInterface db = new DatabaseInterface(this);
    db.open();
    
    Cursor c = db.getNames(); // This would contain _id, name from a database for example.
    
    SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, 
          android.R.layout.simple_spinner_item,
          c,
          new String[] {DatabaseInterface.KEY_ID, DatabaseInterface.KEY_NAME}, 
          new int[] {android.R.id.text1});
    
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);
    

    … This will bind the _id to the spinner id. So when you select an item in the list using the onitemclicklistener like what I posted below. You will have the correct _id’s associated with each of the names in the list…

    spinner.setOnItemClickListener(new OnItemClickListener() {
         public void onItemClick(AdapterView parent, View view, int position, long id){
               // id = the _id from the cursor
         }
    }); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: SQL Server Database query help Hi, I have a problem that I
I'm currently trying to run a LINQ query over a MS SQL database. This
when i give this sql query in my msaccess database table called warehouse1 it
In a SQL Server 2005 database I'm working on this query: select * from
How can I query the database culture (SQL Server 2005) ? I have problems
Can a Linq query retrieve BLOBs from a Sql Database? And how do they
I am working on a SQL query that reads from a SQLServer database to
I'm running an SQL query against a mainframe DB2 database using the OdbcDataReader class
I'm reading data from a table( from a MySQL Database) with Hibernate SQL Query.
In SQL Server how do you query a database to bring back all the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.