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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:21:32+00:00 2026-05-22T19:21:32+00:00

Spinner spinner = new Spinner(this); String option[]={By Date,By Transaction ID,By Customer Phone}; ArrayAdapter<String> spinnerArrayAdapter

  • 0
Spinner spinner = new Spinner(this);
String option[]={"By Date","By Transaction ID","By Customer Phone"};
ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item,option);
spinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item );
spinner.setAdapter(spinnerArrayAdapter);
spinner.performClick();
spinner.setOnItemSelectedListener(new OnItemSelectedListener() {

    @Override
    public void onItemSelected(AdapterView<?> parentview, View v,int position, long id)
    {
        Log.d("in select","yes");
    }

    @Override
    public void onNothingSelected(AdapterView<?> arg0) 
    {
        Toast.makeText(MainMenu.this,"no",Toast.LENGTH_LONG).show();
        Log.d("In No select","No");
    }
});

This all are done very fine, a new pop up display of Spinner view is generate on the previous view and previous view still display but dim, all focus on this current Spinner

But the problem is when I select any item in this spinner then onItemSelected() should be called but it is not called.

but if I write

setContentView(spinner);

then onItemSelected() is called, but then previous view is not displayed now.

so how can i access spinner without this line setContentView(spinner);

I want to get the position of the selected Item in Spinner

Please provide me code or example

i am waiting for your kind reply

  • 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-22T19:21:33+00:00Added an answer on May 22, 2026 at 7:21 pm

    You must bind your spinner to your Layout, if you don’t wont to use setContentView(spinner);. Use something like this at the end of your code

    LinearLayout line = (LinearLayout) findViewById(R.id.line);
    line.addView(spinner);
    

    and your Layout is

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:id="@+id/line">
    </LinearLayout>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the current code: ArrayAdapter adapter = new ArrayAdapter(this,android.R.layout.simple_spinner_item, array_spinner); adapter.setDropDownViewResource( android.R.layout.simple_spinner_dropdown_item );
I'm all new to Android and I'm trying to create a spinner programmatically and
This is my code [...] final String[] top_spinner_items = new String[35]; for (int i
I am new in android. I need to fill the spinner from SQLite database.
I'm quite new to Android development (started 2 days ago) and have been through
Booking.java package one.two; import android.app.Activity; import android.database.Cursor; import android.os.Bundle; import android.widget.ArrayAdapter; import android.widget.SimpleCursorAdapter; import
I'm new to android and programming in general so go easy! I have created
I'm trying to pass a value from an android spinner selection into a url.
This is what I have: import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import
My question is: I am using spinner on my android app. However, I can't

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.