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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:47:46+00:00 2026-05-24T11:47:46+00:00

I recently started programming for android and java development in general. Currently I train

  • 0

I recently started programming for android and java development in general. Currently I train by writing a timetable app.
I want to get a list with all subjects from the db (the table also contains teacher and rooms) and put them into a spinner.
Thats the code I wrote

Cursor c = dba.fetchAllSubjects();

if (c.getCount() != 0)  {
    Spinner subjectSpinner = (Spinner) findViewById(R.id.newlesson_subject);
    startManagingCursor(c);
    String[] from = new String[]{DbAdapter.KEY_SUBJECT}; 
    int[] to = new int[] {android.R.layout.simple_spinner_item};
    SimpleCursorAdapter subjectAdapter = 
        new SimpleCursorAdapter(this, android.R.layout.simple_spinner_item, c, from, to);
    subjectSpinner.setAdapter(subjectAdapter);
}

The problem is that when clicking on the spinner it shows a list with as much items as the db has entries, but the list doesn’t show the names (you can say it’s empty). So I probably messed something up with the simple cursor adapter, but I don’t know what.

Thanks for your help

  • 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-24T11:47:46+00:00Added an answer on May 24, 2026 at 11:47 am

    You’re error lies in specifying the wrong Resource ID in your to integer array.

    int[] to = new int[] {android.R.layout.simple_spinner_item};
    

    You need to specify the ID of a TextView (or similarly typed view) and not the layout itself. Replace the line above with:

    int[] to = new int[] { android.R.id.text1 };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've started Android programming recently so bear with me :) I develop an app
I recently started diving into low level OS programming. I am (very slowly) currently
Recently I was asked if I could help someone to get quick-started to android
I recently started programming for Android using the Eclipse ADT. What I am frequently
I recently started programming my first Cocoa app. I have ran into a problem
I do Java programming and recently started learning Python via the official documentation. I
I just recently started with object oriented programming, using java. Before I was programming
This is my first post, and I've only recently started programming for Android and
I have recently started programming android apps (put simply, i have next to no
I've recently started learning and exploring the basics of GUI programming in Java. Having

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.