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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:54:11+00:00 2026-05-24T05:54:11+00:00

I am using a SimpleCursorAdapter on my spinner because I want to create a

  • 0

I am using a SimpleCursorAdapter on my spinner because I want to create a custom dropDownList that contains multiple rows and populate it from my database. I have accomplished this task quite nicely, but on my layout activity, the spinner shows the selected rows and I would like it to have a separate layout so it shows only the first line of the selected row. How can I accomplish this?

String fields[] = {"name", "lovibond", "gravity"};
    nameAdapter = new GrainSpinnerAdapter(this, R.layout.grain_spinner_row, data, fields, new int[] { R.id.GrainSpinnerName, R.id.GrainSpinnerLovibond, R.id.GrainSpinnerGravity });
    nameSpinner.setAdapter(nameAdapter);

Here is my SimpleCursorAdapter code:

public class GrainSpinnerAdapter extends SimpleCursorAdapter {

    private Context myContext;

    public GrainSpinnerAdapter(Context context, int layout, Cursor c, String[] from, int[] to) {
        super(context, layout, c, from, to);
        myContext = context;
    }

    @Override
    public void bindView(View view, Context context, Cursor cursor) {
        super.bindView(view, context, cursor);

        int nameColumn = cursor.getColumnIndex("name");
        String getName = cursor.getString(nameColumn);
        TextView name = (TextView)view.findViewById(R.id.GrainSpinnerName);
        name.setText(getName);

    }

    @Override
    public View newView(Context context, Cursor cursor, ViewGroup parent) {
        super.newView(context, cursor, parent);
        View view = View.inflate(context, R.layout.grain_spinner, null);
        return view;
    }

    @Override
    public View newDropDownView(Context context, Cursor cursor, ViewGroup parent) {
        super.newDropDownView(context, cursor, parent);

        View view = View.inflate(context, R.layout.grain_spinner_row, null);
        int nameColumn = cursor.getColumnIndex("name");
        String getName = cursor.getString(nameColumn);
        TextView name = (TextView)view.findViewById(R.id.GrainSpinnerName);
        name.setText(getName);

        int loviColumn = cursor.getColumnIndex("lovibond");
        String getLovi = cursor.getString(loviColumn);
        TextView lovi = (TextView)view.findViewById(R.id.GrainSpinnerLovibond);
        lovi.setText(getLovi);

        int gravityColumn = cursor.getColumnIndex("gravity");
        String getGravity = cursor.getString(gravityColumn);
        TextView gravity = (TextView)view.findViewById(R.id.GrainSpinnerGravity);
        gravity.setText(getGravity);

        return view;
    }
  • 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-24T05:54:11+00:00Added an answer on May 24, 2026 at 5:54 am

    I think what you are asking is the getDropDownView() method of BaseAdapter class.

    In your newView method do what you’ve done and provide a layout for single row displays.

    Then implement newDropDownView to inflate another layout that provides for multiple lines.
    The drop down views are used to create rows in the popup menu that is provided when a user selects the dropdown.

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

Sidebar

Related Questions

I've populated a ListActivity from a Cursor using SimpleCursorAdapter that starts another activity when
I've got a class that creates a list from a DB using SimpleCursorAdapter. I
I've bound data from a SQLite database table to a ListView using a SimpleCursorAdapter
I got a Spinner element which I populate with data from a Cursor using
I've created a custom adapter for my spinner because I wanted to have multiple
Say my application has a ListView that displays information from a Sqlite database, using
I have a custom adapter extended from the SimpleCursorAdapter. Using this I'm binding a
I have a main activity that takes elements from a database and displays them
I have a ListView and I'm using SimpleCursorAdapter to populate the content, and newView
I have a ListView in my activity that is populated from a database Cursor

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.