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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:59:51+00:00 2026-06-01T02:59:51+00:00

I need an OnClickListener to my Spinner. I tryed everything i found on the

  • 0

I need an OnClickListener to my Spinner.

I tryed everything i found on the internet, but none of them worked.
Please give me a solution for this:

Got my spinner here:

     spinner = (Spinner)findViewById(R.id.spinner1);

     ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource
     (this, R.array.gyerekek_array, R.layout.my_spinner);

     adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);



     spinner.setAdapter(adapter);
     spinner.setOnItemSelectedListener(new ItemChooser());

And this is my_spinner.xml:

<?xml version="1.0" encoding="utf-8"?>
   <TextView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_height="fill_parent"
    android:layout_width="fill_parent" 
    android:gravity="center_vertical|center_horizontal"
    android:textColor="#000000"
    android:paddingLeft="50dp"
    android:text="Sample Text" 
    android:textStyle="bold"
    android:textSize="31sp"
    >

</TextView>

I tryed everything from stackoverflow and everything else from the internet. I just cant make it…
I cannot add onClickListener to the spinner’s default TextView because i dont use the default spinner, i got my own my_spinner.xml.
In Fact, if i add an “ID” to my Text View inside the my_spinner.xml i got a null pointer exception.

I even tryed to add an invisible TextView atop of the Spinner, but then only one view can be sensored by OnClick.

Please help me guys.

  • 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-01T02:59:53+00:00Added an answer on June 1, 2026 at 2:59 am

    you can’t add an onclicklistener on any adapter view try to use setOntouchlistener hope it will help you

    spinner = (Spinner)findViewById(R.id.spinner1);
    
         ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource
         (this, R.array.gyerekek_array, R.layout.my_spinner);
    
         adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    
         spinner.setOnTouchlistener(this); 
    
         spinner.setAdapter(adapter);
         spinner.setOnItemSelectedListener(new ItemChooser());
    

    //////////////////////////// your listener

    public boolean onTouch(View v, MotionEvent event) {
            Log.d("Spinner","clicked");
            return false;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have spent many hours looking for a solution to this and need help.
Hy,i need to have an onclick on a spinner. This is my spinner: Spinner
Need to apply a filter to a file like this: TUPAC_0006:1:1:2554:2356#0/1 0 * 0
Need a map reduce function by mongo in php This my mongo structure [_id]
Need just a push in the right direction with this. I'm building a multi-language
When I run this code, it shows error. Please, help me out. I'm trying
simple question what do i need to add to this code so that when
We usually code like this innner OnClickListener : new OnClickListener (){ void onClick(View v){
i want execute populateFields if the spinner changed but i don't know how i
I'm developing an application where I need to turn off and on the onClicKListener

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.