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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:24:33+00:00 2026-06-15T22:24:33+00:00

I have a spinner which is populated from the database. So if the spinner

  • 0

I have a spinner which is populated from the database. So if the spinner is clicked with no items in it,a spinner with an empty list item is shown.I want to avoid showing the spinner when it is empty and show a toast message. I have the logic to check the count of the items and show the toast message, but I cannot find out where to call the function.What is the event called when clicking the spinner and loading the spinner items?

  • 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-15T22:24:34+00:00Added an answer on June 15, 2026 at 10:24 pm

    Spinner is a subclass of View, so, View.setOnClickListener() can be used to change onClick() implementation which will be called when it is clicked. You can override onClick() to check if the Spinner is empty and then show the Toast.

    Correction:

    Since you cannot setOnClickListener for Spinner, you can use the solution suggested in this question (the contents of which I’ve pasted below).

    Instead of setting the spinner’s OnClickListener, we are setting OnTouchListener and OnKeyListener.

    spinner.setOnTouchListener(Spinner_OnTouch);
    spinner.setOnKeyListener(Spinner_OnKey);
    

    and the listeners:

    private View.OnTouchListener Spinner_OnTouch = new View.OnTouchListener() {
        public boolean onTouch(View v, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_UP) {
                doWhatYouWantHere();
            }
            return true;
        }
    };
    private static View.OnKeyListener Spinner_OnKey = new View.OnKeyListener() {
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER) {
                doWhatYouWantHere();
                return true;
            } else {
                return false;
            }
        }
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a spinner witch is populated from database, when I select an item
I have spinner which I populate from SQLite database. But I want to populate
So, at the moment I have a spinner which is populated from a database
I have a spinner which is populated from the database. This in turn is
I have an application, which has a Spinner that I want populated with some
I have a ListView in which each List item has a Spinner . I
I have spinner which populates from database: catSpinner = (Spinner) findViewById(R.id.spinner1); cursor = dataAdapter.getAllCategory();
I have a spinner which is populated with Category objects that are retrieved from
Hi i have an android spinner populated from and array that i want to
I have a spinner which is populated from an Enum: public enum Frequencies {

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.