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

  • Home
  • SEARCH
  • 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 3967510
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T03:43:42+00:00 2026-05-20T03:43:42+00:00

I have a Spinner that’s populated using a cursor containing data from a database.

  • 0

I have a Spinner that’s populated using a cursor containing data from a database. It appears that it’s impossible to set the selected item in the spinner using the value of the ID column of a row. And that the only way to set the selected item is by using the position of the row within the dataset. Is this correct? If so, is there a more efficient way of determining the row’s position than by iterating through the dataset using the cursor?

The inefficient (to my mind) way is outlined here.

Thanks much!

  • 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-20T03:43:43+00:00Added an answer on May 20, 2026 at 3:43 am

    First step, create view for your data set, with joins etc.:

    CREATE VIEW my_view AS
      SELECT _id, field FROM my_table
    

    Second step:

    CREATE VIEW my_view2 AS
      SELECT count(*) AS row_id, q1.*
      FROM my_view AS q1
      LEFT JOIN my_view AS q2
      WHERE q1._id >= q2._id
      GROUP BY q1._id
    

    Then simply:

    SELECT * FROM my_view2
    

    Results:

    row_id | _id | field
    
    1   4   XbMCmUBFwb
    2   6   Te JMejSaK
    3   8   dDGMMiuRuh
    4   10  phALAbnq c
    5   11  EQQwPKksIj
    6   12  PAt tbDnf
    7   13  f zUSuhvM
    8   14  TIMBgAGhkT
    9   15  OOcnjKLLER
    

    To get position by id:

    SELECT * FROM my_view2 WHERE _id=11
    

    Results:

    row_id | _id | field
    
    5   11  EQQwPKksIj
    

    Hope that help

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an android spinner that's populated by a list of strings using an
So, at the moment I have a spinner which is populated from a database
I have an application, which has a Spinner that I want populated with some
I have a little iPhone app that loads data from a web service. To
I have a Spinner with an ArrayAdapter that feeds Values into it. The layout
It appears that android's Spinner class (and possibly ListView in general, although I don't
I have an Android Spinner view in my layout. I would like that spinner
Hello I have question about android spinner I have spinner which is populated by
Hello I have question about android spinner I have spinner which is populated by
I need to probabilistically select a sample from a set of data. Say I

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.