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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T11:51:14+00:00 2026-05-16T11:51:14+00:00

The java.lang.RuntimeException is Don’t call setOnClickListener for an AdapterView. You probably want setOnItemClickListener instead,

  • 0

The java.lang.RuntimeException is “Don’t call setOnClickListener for an AdapterView. You probably want setOnItemClickListener instead,” but that is not correct. I am using setOnItemClickListener to do some stuff based on the new selection, but I also need to do some stuff before the user changes the selection. Specifically, I am collecting data for each selection that needs to be saved to a file before moving to another selection, since the other selection is associated with different set of data. Is there a way to use setOnClickListener with an Android Spinner?

spinner.setOnClickListener(new View.OnClickListener() {
    public void onClick(View v) {
        // Do some stuff before the user changes the selection
        ...

spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
    @Override
    public void onItemSelected(AdapterView<?> parent,
            View view, int pos, long id) {
            // Do some stuff based onItemSelected
            ...
  • 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-16T11:51:15+00:00Added an answer on May 16, 2026 at 11:51 am

    You will have to set the Click listener on the underlying view (normally a TextView with id: android.R.id.text1) of the spinner. To do so:

    • Create a custom Spinner
    • In the constructor (with attributes) create the spinner by supplying the layout android.R.layout.simple_spinner_item
    • Do a findViewById(android.R.id.text1) to get the TextView
    • Now set the onClickListener to the TextView
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When overriding the equals() function of java.lang.Object, the javadocs suggest that, it is generally
During navigation of the java.lang.reflect.Method class I came across the method isBridge . Its
If you decompile the java.lang.Class class in java from the rt.jar library you will
JBOSS is throwing a: java.lang.NoSuchMethodError: org.w3c.dom.Document.getDocumentURI()Ljava/lang/String; Error when loading a wsdl. Can I configure
What are Null Pointer Exceptions ( java.lang.NullPointerException ) and what causes them? What methods/tools
What's the difference between java.lang.ref.WeakReference and java.lang.ref.SoftReference ?
I've been hitting a java.lang.OutOfMemoryError: PermGen error when compiling a project with ant under
In what situations should one catch java.lang.Error on an application?
Java 5 introduced generics, and they were added to many interfaces in the java.lang
Recently I ran into this error in my web application: java.lang.OutOfMemoryError: PermGen space It's

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.