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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:21:49+00:00 2026-06-13T17:21:49+00:00

I try to attach a on select event to my Android android.widget.Spinner I know

  • 0

I try to attach a on select event to my Android android.widget.Spinner

I know Spinner.setOnItemSelectedListener exist but not work as I want,
The problem with the setOnItemSelectedListener is that method is call while the spinner is load with a Adapter and as predefine a item is select.

I want a interface for get a event while a “user” select a item from the Spinner by use the tuch screen. Also a event that only is call while the use select a item and not the program select a item.

I want a event that is call while the use select a item from this spinner dialog.

enter image description here

  • 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-06-13T17:21:50+00:00Added an answer on June 13, 2026 at 5:21 pm

    I have finally find a solution that works for me, by look at the code on http://www.oschina.net/code/explore/android-4.0.1/core/java/android/widget/Spinner.java

    I found out how to prevent or attach more code to this code part that is run while the use will show the dropdown list and then create my one instace of Spinner.

    My spinner class has a use define interface OnSelectSpinnerListener that will be run while the user tuch the spinner and then select a item from the spinner list.

    /**
     * Create a DropDown Spinner/Select List, that also has some event for detect
     * action do by the use and action do by the system.
     *
     * Use {@link OnSelectSpinnerListener} for attach a listener to this
     * SelectSpinner.
     */
    public class SelectSpinner extends Spinner {
    
        public interface OnSelectSpinnerListener {
    
            /**
             * Call before the drop down menu is show that allow use to select one
             * of the item from the Spinner.
             */
            public void onOpenSelectMenu();
    
            /**
             * Call while the use press a button or item for select this. This will
             * not be call while the system set a select value for the spinner. Use {@link SelectSpinner#setOnItemSelectedListener(android.widget.AdapterView.OnItemSelectedListener)}
             * for get all event while a item is set to the spinner.
             *
             * @param index Select item as Index
             * @param object Select item as Object
             */
            public void onItemSelectByUser(int index, Object object);
        }
        private OnSelectSpinnerListener onSelectSpinnerListener;
    
        public SelectSpinner(Context context) {
            super(context);
    
        }
    
        public SelectSpinner(Context context, AttributeSet attrs) {
            super(context, attrs);
        }
    
        public SelectSpinner(Context context, AttributeSet attrs, int defStyle) {
            super(context, attrs, defStyle);
        }
    
        public OnSelectSpinnerListener getOnSelectSpinnerListener() {
            return onSelectSpinnerListener;
        }
    
        public void setOnSelectSpinnerListener(OnSelectSpinnerListener onSelectSpinnerListener) {
            this.onSelectSpinnerListener = onSelectSpinnerListener;
        }
    
        @Override
        public void onClick(DialogInterface dialog, int which) {
            super.onClick(dialog, which);
            if (this.onSelectSpinnerListener != null) {
                Object item = super.getItemAtPosition(which);
                this.onSelectSpinnerListener.onItemSelectByUser(which, item);
            }
        }
    
        @Override
        public boolean performClick() {
            if (this.onSelectSpinnerListener != null) {
                this.onSelectSpinnerListener.onOpenSelectMenu();
            }
            return super.performClick();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I try to attach event handler functions with parameters like : myhandle.onclick =
My app successfully makes email but when I try to attach an image the
Try to see which cast is faster (not necessary better): new c++ case or
when i try to attach entity to context i get an exception An object
I am developing a payroll add-on for SAP Business One. I try to select
I have used the Attach to process function within VS 2008 many times, but
I got a hard job to be done. I try to attach additional information
When I try to attach a .mdf file in Management Studio to open it
I'm getting this message when I try and attach to process. How do I
I get the following dialog box when I try to attach VS2008 debugger to

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.