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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:04:05+00:00 2026-05-24T23:04:05+00:00

I am rather new at Android and am having some issues in understanding the

  • 0

I am rather new at Android and am having some issues in understanding the usage of cwac-MergeAdapter.

I am trying to use MergeAdapter to populate a spinner; my instance of MergeAdapter should include a SimpleCursorAdapter, which is correctly reading data from my db, and (as a footer) a new TextView (or Button) which should be clickable.

Currently, if I feed the spinner the mergeAdapter containing only data from the db, everything works like a charm; however, as I add the new view, I only get a single, blank entry in the whole spinner. Can someone please help me with this?

Here follows the code:

essenceItems = new SimpleCursorAdapter(this, R.layout.db_row_view,
    essenceCursor, from, to);

    TextView addEssence = new TextView(getApplicationContext());
    addEssence.setTextColor(R.color.red);
    addEssence.setText("Add new item...");
    addEssence.setWidth(ViewGroup.LayoutParams.FILL_PARENT);
    addEssence.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
    addEssence.setOnClickListener(new OnClickListener() {

       public void onClick(View v) {
         startActivityForResult(new Intent(v.getContext(),
         EssencePopup.class), ADD_ESSENCE);

     }
     });
    ma = new MergeAdapter();
    ma.addAdapter(essenceItems);
    ma.addView(addEssence, true);
    spinner.setAdapter(ma);
  • 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-24T23:04:05+00:00Added an answer on May 24, 2026 at 11:04 pm

    It is unlikely that I will ever support adding individual Views to a MergeAdapter to be used in a Spinner. That would imply that I somehow know how to create a drop-down View for some arbitrary View.

    The workaround I have for you is for you to add the following to your fork of MergeAdapter:

    public View getDropDownView(int position, View convertView, ViewGroup parent) {
      for (ListAdapter piece : pieces) {
        int size = piece.getCount();
    
        if (position < size) {
          return (((SpinnerAdapter)piece).getDropDownView(position, convertView, parent));
        }
    
        position -= size;
      }
    
    return (null);
    }
    

    Then, instead of adding an individual View via addView(), add your own ArrayAdapter for your additional data. Be sure to call setDropDownViewResource() on all your adapters inside of the MergeAdapter — your sample code never called this, causing some of your other difficulties (e.g., “some entries in the spinner are blank”).

    It is possible that I will merge this change into MergeAdapter, or perhaps will create a SpinnerMergeAdapter subclass with it. The blind cast to SpinnerAdapter scares me, which is why I want to ponder this a bit more. In light testing, the code I have above seems to work OK.


    Also, please delete all occurrences of getApplicationContext() from your code, replacing it with this or WhateverYourActivityNameIs.this as appropriate. Only use getApplicationContext() when you know why you are using getApplicationContext().

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

Sidebar

Related Questions

I'm rather new to Android development, and am trying to learn with a bit
I am rather new to Android programming in general and am having particular difficulty
I'm rather new to jQuery and I'm trying to make a cool little menu
I am rather new to VIM. I got some source code and this is
I hope this isn't a dumb question, as I am rather new to Android,
I'm trying to do something rather simple here, just launch a new activity from
I'm rather new to Android and I'm working on an app that is registered
I am rather new to Android programming and Java in general (like… one week
I'm currently using Monodroid to develop an android app. I'm rather new to phone
I'm rather new to both Java programming and to Android development, so my learning

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.