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

  • Home
  • SEARCH
  • 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 9226777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:54:41+00:00 2026-06-18T04:54:41+00:00

This is how i define the spinner s_province = (Spinner) findViewById(R.id.s_province); ArrayAdapter<String> provinceAdapter =

  • 0

This is how i define the spinner

s_province = (Spinner) findViewById(R.id.s_province);
        ArrayAdapter<String> provinceAdapter = new ArrayAdapter<String>(this,
                android.R.layout.simple_spinner_item, Data.provinces);
        provinceAdapter
                .setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        s_province.setAdapter(provinceAdapter);
        s_province.setOnItemSelectedListener(this);

my class is implement from OnItemSelectedListener and i override this methods

@Override
    public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2,
            long arg3) {
        // TODO Auto-generated method stub
        switch (arg1.getId()) {
        case R.id.s_province:
            Log.d("here", "there");
            break;

        default:
            break;
        }
    }

    @Override
    public void onNothingSelected(AdapterView<?> arg0) {
        // TODO Auto-generated method stub

    }

but the onItemSelect is not triged , why please?

  • 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-18T04:54:42+00:00Added an answer on June 18, 2026 at 4:54 am

    Two things:

    1. If you actually want to check if your method is working put a Log statement outside the switch or in the default case so that you can be sure the method is being called.

    2. You should be using arg2 since that represents position. Make your switch work with positions instead of whatever View is passed. Also rename your variables from the default names Eclipse assigns. arg0,1,2, etc are not helpful for you nor for anyone else looking at your code.

    Eg

    @Override
    public void onItemSelected(AdapterView<?> parent, View view, int position, long id){
      Toast.makeText(view.getContext(),"onItemSelected called", Toast.LENGTH_LONG).show();
      int spinnerId = parent.getId();
      if (spinnerId == R.id.s_province)
      {
        switch (position)
        {
          case 0: 
            //do something if first position was clicked
          break:
          case 1:
            //do something else
            break;
          default: 
            //if for any reason no position matches.
            break;
        }
      }
      else if (spinnerId == R.other_id_in_xml)
      {
        switch (position)
        {
          case 0: 
            //do something if first position was clicked
          break:
          case 1:
            //do something else
            break;
          default: 
            //if for any reason no position matches.
            break;
        }
      }
      //etc
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've created a Dojo module which depends on dojox/data/JsonRestStore like this: define(my/MyRestStore, [dojo/_base/declare, dojox/data/JsonRestStore],
I have a Spinner with an ArrayAdapter that feeds Values into it. The layout
I want to implement two different spinner in Android, the spinner have different data
I'm trying to use #define to define a string literal (a filepath in this
I have tried this: #define format(f, ...) \ int size = strlen(f) + (sizeof((int[]){__VA_ARGS__})/sizeof(int))
I'm using a struct like this: define struct _Fragment{ int a; char *seq; }Fragment;
I have some Objective-C code that looks like this: #define myVar 10 float f
I have a library that has several options defined as this: #define shouldShowToolbar YES
I have a file that defines constant variables, like this: define_vars.php <? define(something,value); define(something1,value);
When I define this function, template<class A> set<A> test(const set<A>& input) { return input;

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.