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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:19:11+00:00 2026-05-23T07:19:11+00:00

I am creating a Spinner instance that I bind to my own custom adapter

  • 0

I am creating a Spinner instance that I bind to my own custom adapter class (derived from BaseAdapter). In it, I create a bunch of custom “cell” LinearLayout-derived instances that I inflate from xml to be used for each item in the spinner.

Everything looks fine as expected, but whenever the items in “drop down” mode are clicked, the drop down dialog does not get dismissed.

I can trap the click notification inside my cell class, but what is the magic sauce I need to tell the spinner that an item was selected and that it should dismiss the drop down?

My cell class is inflated from the following xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:id="@+id/VIEW_LEAF" 
                          android:layout_width="fill_parent" 
                          android:layout_height="wrap_content"
                          android:orientation="horizontal"
                          >

  <TextView android:id="@+id/STATIC_LEAF_NAME" 
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"            
            android:gravity="left"
            android:paddingLeft="3dip" 
            android:paddingTop="20dip" 
            android:paddingBottom="20dip" 
            android:textSize="22sp" 
            android:textStyle="bold"
            android:text=""
            android:layout_gravity="left|center_vertical"
            android:textColor="@color/black_enabled_grey_disabled"
            />

</LinearLayout>

My cell class looks like so:

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.widget.LinearLayout;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import android.view.View.OnClickListener;

// This class is responsible for rendering the data in the model.

public class DataCell extends LinearLayout implements OnClickListener
{
  private final String TAG = getClass().getSimpleName();

    public DataCell(Context context)
    {
        super(context);
        m_context = context;

        final boolean attachToRoot = true;
        LayoutInflater.from(context).inflate(R.layout.data_cell, 
                this, attachToRoot);

    m_labelName = (TextView) findViewById(R.id.STATIC_LEAF_NAME);
    m_labelName.setOnClickListener(this);
    }

    // Update the views with the data corresponding to selection index.
    // If dropDown is true, this view is to be displayed in a dropped down
    // list.
    public void display(int index, ViewGroup parent, Data data, boolean dropDown)
    {
      m_data = data;
        m_labelName.setText(data.getFriendlyName());

        setFocusable(true);
    }

  @Override
  public void onClick(View view)
  {
    ViewParent parent = getParent();
    if(parent instanceof Spinner)
    {
      //((Spinner)parent).setSelection(2);// TODO something here?
    }
  }

  private TextView m_labelName = null;

  @SuppressWarnings("unused")
  private Context m_context = null;

  @SuppressWarnings("unused")
  private Data m_data = null;
}

Thanks!
swine

  • 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-23T07:19:11+00:00Added an answer on May 23, 2026 at 7:19 am

    So you were right about the cell stealing the clicks. But there was a very simple solution to all this, just not very obvious. All I had to do is make the TextView inside my DataCell not respond to clicks.

    So I removed the m_labelName.onClickListener() call completely, and instead, at that location, put in the following code:

    m_labelName.setClickable(false);
    m_labelName.setFocusable(false);
    m_labelName.setFocusableInTouchMode(false);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating a custom Spinner that shows a custom Dialog. For that, I created
I'm creating a custom Dialog that is started by a custom spinner. What I
I am creating a custom adapter , simple stuff and it is exploding on
I'm creating an alert dialog with a spinner graphic. UIAlertView *alert; //(at top of
Creating liquid layouts is an immense pain. Now, I totally understand that tables should
I'm creating a spinner in my layout xml files and setting an string array
Creating a site in with FrogCMS and using alot of jquery to create an
Creating a Drawable that is completely empty seems like a common need, as a
I'm having a spinner which is populated with a CursorAdapter . Now when creating
I'm writing an android app that has a spinner in it for difficulty settings

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.