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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:59:07+00:00 2026-05-28T16:59:07+00:00

First a little background about why I’m asking this question… I’m working on a

  • 0

First a little background about why I’m asking this question…

I’m working on a scheduling app for a machine shop. I have a database with tables for the machines, jobs and employees. It’s possible that not all of these machines will have jobs or operators, so I needed a way to add “None” to the spinners (there are several reasons I won’t go into for not adding that to the database itself). To accomplish this I settled on getting a cursor from the database and iterating over it, loading those bits I needed into an ArrayList and adding a “None” element at the end.

This works just fine, but now I’ve come upon a sticking point I can’t seem to figure out.

The Job table has two columns (not counting the index): a job number and a part number. I created a custom layout to put them together and then use that in the spinner (so you would see Job # – Part # on each line of the spinner). Populating that from a cursor was simple. Trying to convert that to two arrays has me stumped.

I can get the data from the cursor into the two arrays with no problem, but I can’t figure out how to relate them to the layout ids contained in the layout.

I’m new to android and long time ago schooled in Java, so if I’ve missed something obvious, please point it out!

listlayoutdouble.xml :

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:orientation="horizontal" >

    <TextView
        android:id="@+id/ListItem1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:minHeight="?android:attr/listPreferredItemHeight"
        android:paddingLeft="12dip"
        android:gravity="left|center_vertical"
        android:layout_weight="1"       
        android:textAppearance="?android:attr/textAppearanceLarge" />

    <TextView
        android:id="@+id/ListItem2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:minHeight="?android:attr/listPreferredItemHeight"
        android:paddingRight="12dip"
        android:gravity="right|center_vertical"
        android:layout_weight="1"
        android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>

What I have so far:

private void fillJobSpinner() {
        Cursor jobsCursor = mDBHelper.fetchAllJobs();
        startManagingCursor(jobsCursor);

        ArrayList<String> jobnumbers = new ArrayList<String>();
        ArrayList<String> jobnparts = new ArrayList<String>();
        if (jobsCursor != null) {
            operatorsCursor.moveToFirst();
            while (operatorsCursor.isAfterLast() == false) {
                jobnumbers.add(jobsCursor.getString(jobsCursor
                        .getColumnIndex(ScheduleDBAdapter.JOB_NUMBER))); 
                jobnparts.add(jobsCursor.getString(jobsCursor
                        .getColumnIndex(ScheduleDBAdapter.JOB_PART))); 
                jobsCursor.moveToNext();
            }
            jobnumbers.add("None");
            jobparts.add("None");
        }
}
  • 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-28T16:59:08+00:00Added an answer on May 28, 2026 at 4:59 pm

    I think what you need is a custom adapter for your spinner.

    You need to extend BaseAdapter

    http://developer.android.com/reference/android/widget/BaseAdapter.html

    Then override the getView method.

    A quick google turned up this tutorial:

    http://app-solut.com/blog/2011/03/using-custom-layouts-for-spinner-or-listview-entries-in-android/

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

Sidebar

Related Questions

This is my first question :). Im writing a little twitter app in PHP
First I will give a little background info so this question isn't completely without
First a little background. I am building a mobile app for a client, this
I am working on this site: http://www.problemio.com and I have very little clue about
First, a little background. I have strings that resemble the following: ((Foo.Bar.StartsWith(A)) && (Foo.Bar.EndsWith(B)))
First question on here so please be nice :) I know very little about
First, a little background : I have written a little application in python with
Background: I have a little video playing app with a UI inspired by the
First a little background info: I have UIViewController that contains a UITableView. In the
First, a little background (greatly simplified): I have two classes, one called Entity and

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.