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 6937967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:25:52+00:00 2026-05-27T12:25:52+00:00

I have a simple database table with 2 columns _id and title. and I’m

  • 0

I have a simple database table with 2 columns “_id” and “title”.
and I’m displaying the data in a spinner, and it works well.

but I need to add one more item at the top of the spinner list that is not from the database with id = 0 and title = “not specified”;

Spinner list = (Spinner) findViewById(R.id.spinner);
Cursor cursor = database.getAll(); // returns cursor with objects

String[] columns = new String[] {"title"};
int[] to = new int[] {R.id.title};

list.setAdapter(new SimpleCursorAdapter(this, R.layout.object_item_simple, cursor, columns, to));

I need to know the selected item id from the database, i can do this with list.getSelectedItemId();

so I can’t use ArrayAdapter instead of SimpleCursorAdapter, because i don’t think that there is a method for setting the id for each item on the adapter.
is there a way to do this?

Thanks.

  • 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-27T12:25:53+00:00Added an answer on May 27, 2026 at 12:25 pm

    You could create an object out of your id and title and build a list of these objects with the cursor. Then insert your artificial entry at the top top of that list.

    Then when you construct your Adapter pass in this list.

    Alternatively you could put a dummy value into your database, although that would be weird and maybe not possible depending on your query and data. The ArrayAdapter is much more sensible

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

Sidebar

Related Questions

I have a database full of simple note data, with columns for title, due
I have simple table with two columns: id INTEGER as a key, and data
I have a simple database table called Entries: class CreateEntries < ActiveRecord::Migration def self.up
I have two simple tables in my database. A card table that contains Id,
I have a table in a MySQL database that I am running simple SELECT
i have a database that already has a users table COLUMNS: userID - int
I have a simple table in my SQL Server database. This table contains two
I am working with an SQLAlchemy database. I have a simple schema with columns
I have a simple database with few tables (and some sample columns): Posts (ID,
Lets say I have a simple table that only contains two columns: MailingListUser -

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.