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 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'm all new to Android and I'm trying to create a spinner programmatically and
New to android development, be gentle haha. I am wanting to populate a spinner
I am new in android. I need to fill the spinner from SQLite database.
I created a Loading spinner in a SWF. I display this spinner in my
Why do I not see the spinner image when I run this code? However
I am having an Android view with a Spinner on it. I call a
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 abit new to programming Android App's, however I have come across a problem,
String[] songList = { 1, 2, 3, }; Spinner sp; TextView selection; @Override public
I have a spinner, and I do this public class Settings extends Activity {

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.